Pastebin launched a little side project called HostCabi.net, check it out ;-)Don't like ads? PRO users don't see any ads ;-)
Guest

MySQL++ Table Creation Problem

By: a guest on Jan 15th, 2013  |  syntax: C++  |  size: 0.95 KB  |  hits: 27  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  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. }