Hi Tommi! I am trying to use the new SqlBuilder class to handle list-placeholders. First of all: Great to have something to make this easier! From a library user's point of view, though, it would be nicer to have this feature built into tntdb::Statement, so that you could set scalar and list placeholders in one go. Currently it seems that you have to do: 1. Create a SqlBuilder object. 2. Handle list placeholders. 3. Create a Statement object. 4. Handle scalar placeholders. – which seems quite a lot.
Apart from that, SqlBuilder does not actually work for me, unfortunately. I tried using both its method "replace" and "extendParam", but neither seems to perform any replacing/extending: When I print the query as a string, the original placeholder is still in place. See the attached source file for details on what I tried. Am I doing somethin wrong? I am using the release candidates of Tntdb (1.2rc2) and Cxxtools (2.1rc3). Carlos
/*
* test.cpp
*/
#include <iostream>
#include <vector>
#include <tntdb/connect.h>
#include <tntdb/connection.h>
#include <tntdb/result.h>
#include <tntdb/statement.h>
#include <tntdb/sqlbuilder.h>
int main(int argc, char *argv[])
{
tntdb::Connection db = tntdb::connect("sqlite:/home/carlos/.local/share/savant/savant.sqlite");
tntdb::SqlBuilder query_string ("select distinct entry_id"
" from index_terms"
" where entry_id in (:subset)");
std::cout << "replace:\n" << query_string.replace("subset", "1,2,3").str() << std::endl;
//tntdb::Statement statement_with_subset = db.prepare(query_string.replace("subset", "1,2,3").str());
std::cout << "extendParam:\n" << query_string.extendParam("subset", 3).str() << std::endl;
//tntdb::Statement statement_with_subset = db.prepare(query_string.extendParam("subset", 3))
// .set("subset0", 1)
// .set("subset1", 2)
// .set("subset2", 3);
//tntdb::Result result_with_var = statement_with_subset.select();
//std::cout << "\nResult from statement_with_var:" << std::endl;
//for (tntdb::Result::const_iterator i = result_with_var.begin(); i != result_with_var.end(); ++i)
// std::cout << (*i)[0].getInt() << std::endl; //never called
return 0;
}
signature.asc
Description: PGP signature
------------------------------------------------------------------------------ Virtualization & Cloud Management Using Capacity Planning Cloud computing makes use of virtualization - but cloud computing also focuses on allowing computing to be delivered as a service. http://www.accelacomm.com/jaw/sfnl/114/51521223/
_______________________________________________ Tntnet-general mailing list [email protected] https://lists.sourceforge.net/lists/listinfo/tntnet-general
