
MySQL++ Table Creation Problem
By: a guest on
Jan 15th, 2013 | syntax:
C++ | size: 0.95 KB | hits: 19 | expires: Never
mysqlpp::Query query = connection.query(true);
queries = {"CREATE TABLE t1 ...", "CREATE TABLE t2 ...", "CREATE TABLE t3..."};
tables = {"t1", "t2", "t3"};
// sz = is the size of "queries"
for (i = 0; i < sz; ++i){
query.reset();
if (!tableExists(tables[i])){
query << queries[i];
query.execute();
// Technically, I should need the lines below, since,
// according to the MySQL++ documentation on Query.reset():
// As of v3.0, Query objects auto-reset upon query execution unless
// you've set it up for making template queries. (It can't auto-reset
// in that situation, because it would forget the template info.)
// Therefore, the only time you must call this is if you have a Query
// object set up for making template queries, then want to build queries
// using one of the other methods. (Static strings, SSQLS, or the stream
// interface.)
query.reset();
while(query.more_results()){
query.store_next();
}
}
}