Advertisement
Guest User

MySQL++ Table Creation Problem

a guest
Jan 15th, 2013
122
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.95 KB | None | 0 0
  1. mysqlpp::Query query = connection.query(true);
  2. queries = {"CREATE TABLE t1 ...", "CREATE TABLE t2 ...", "CREATE TABLE t3..."};
  3. tables = {"t1", "t2", "t3"};
  4. // sz = is the size of "queries"
  5. for (i = 0; i < sz; ++i){
  6.     query.reset();
  7.     if (!tableExists(tables[i])){
  8.         query << queries[i];
  9.         query.execute();
  10.         // Technically, I should need the lines below, since,
  11.         // according to the MySQL++ documentation on Query.reset():
  12.         //  As of v3.0, Query objects auto-reset upon query execution unless
  13.         //  you've set it up for making template queries. (It can't auto-reset
  14.         //  in that situation, because it would forget the template info.)
  15.         //  Therefore, the only time you must call this is if you have a Query
  16.         //  object set up for making template queries, then want to build queries
  17.         //  using one of the other methods. (Static strings, SSQLS, or the stream
  18.         //  interface.)
  19.         query.reset();
  20.         while(query.more_results()){
  21.             query.store_next();
  22.         }
  23.     }
  24. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement