From c0fb139bb6ef0ecef773a60b02e8c7aab0acf955 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9bastien=20Rombauts?= Date: Sat, 9 Mar 2013 12:28:23 +0100 Subject: [PATCH] example updated : the third row converted to float values, and renamed "weigth" instead of "size" --- TODO.txt | 4 ++-- example.db3 | Bin 2048 -> 3072 bytes src/example1/main.cpp | 20 +++++++++++--------- 3 files changed, 13 insertions(+), 11 deletions(-) diff --git a/TODO.txt b/TODO.txt index e612169..333656e 100644 --- a/TODO.txt +++ b/TODO.txt @@ -1,6 +1,6 @@ -C++11 explicit support +Add a Changelog -=> V0.5.0 +C++11 explicit support Update Doxygen Documentation, but remove it from the master branch Publish the Doxygen Documentation in the Github Pages (gh-pages branch) diff --git a/example.db3 b/example.db3 index eef46c06502969bef401bf1867c292ed66e67b2c..c02726b373065345a9ec2756db9080188838e433 100644 GIT binary patch literal 3072 zcmeHIL2AN46rE&3Lj^Yl6}tMxg$lMO#_I5767&sG36Bq2dS3IIYV&kFyPz@7)J zL{@8X?l7+8A5NMX=Nseh8fW`h{@GVV>J{m zNLw9f6bgkx<)p%Tq)SI;-lDAPu^Dr|w=YKq{h0eZgWTTQ9RD{lULgF17kIfFpJwtF zNdh~RKshhZoCkkmgXc~hC7Tl^v`HNdkKHMw VLw{;3;yA);H|a?NNdo^dfp6F-r3?T7 delta 215 zcmZpWXb_knEy%&Zz`z8=Fu*iX$C#gkLHCgYFHne)c{T&{?9GBKy3Cx(jO^l~qKu82 zlN*_({Yz4dOL)07c)1i5GE)>h{X$&bU4s+?f;@d4gCZ5YT_bfsQe}xbrKt)bt`Q-; zTsjKHnN_JUrJB6V=NOoo_cAc=Wq!web2B5ydS+*SMivG|# :min_size")// Compile a SQL query, containing one parameter (index 1) + mDb("example.db3"), // Open a database file in readonly mode + mQuery(mDb, "SELECT * FROM test WHERE weight > :min_weight")// Compile a SQL query, containing one parameter (index 1) { } virtual ~Example(void) { } - /// List the rows where the "size" column is greater than the provided aParamValue + /// List the rows where the "weight" column is greater than the provided aParamValue void ListGreaterThan (const int aParamValue) { std::cout << "ListGreaterThan (" << aParamValue << ")\n"; // Bind the integer value provided to the first parameter of the SQL query - mQuery.bind(":min_size", aParamValue); // same as mQuery.bind(1, aParamValue); + mQuery.bind(":min_weight", aParamValue); // same as mQuery.bind(1, aParamValue); // Loop to execute the query step by step, to get one a row of results at a time while (mQuery.executeStep()) @@ -75,10 +75,11 @@ int main (void) std::cout << "execAndGet=" << value.c_str() << std::endl; // Compile a SQL query, containing one parameter (index 1) - SQLite::Statement query(db, "SELECT * FROM test WHERE size > ?"); + SQLite::Statement query(db, "SELECT * FROM test WHERE weight > ?"); std::cout << "SQLite statement '" << query.getQuery().c_str() << "' compiled (" << query.getColumnCount () << " columns in the result)\n"; - // Bind the integer value 1 to the first parameter of the SQL query - query.bind(1, 1); + // Bind the integer value 2 to the first parameter of the SQL query + query.bind(1, 2); + std::cout << "binded with integer value 2 :\n"; // Loop to execute the query step by step, to get one a row of results at a time while (query.executeStep()) @@ -88,9 +89,9 @@ int main (void) //const char* pvalue = query.getColumn(1); // = query.getColumn(1).getText() std::string value2 = query.getColumn(1); // = query.getColumn(1).getText() int bytes = query.getColumn(1).getBytes(); - int size = query.getColumn(2); // = query.getColumn(2).getInt() + double weight = query.getColumn(2); // = query.getColumn(2).getInt() - std::cout << "row : (" << id << ", " << value2.c_str() << ", " << bytes << ", " << size << ")\n"; + std::cout << "row : (" << id << ", \"" << value2.c_str() << "\" " << bytes << "B, " << weight << ")\n"; } // Reset the query to use it again @@ -98,6 +99,7 @@ int main (void) std::cout << "SQLite statement '" << query.getQuery().c_str() << "' reseted (" << query.getColumnCount () << " columns in the result)\n"; // Bind the string value "6" to the first parameter of the SQL query query.bind(1, "6"); + std::cout << "binded with string value \"6\" :\n"; while (query.executeStep()) {