13 messages in com.mysql.lists.plusplusRe: Weird parsing of templated query
FromSent OnAttachments
Steven Van Ingelgem14 Jul 2007 10:49 
Andrew Sayers14 Jul 2007 13:00 
Warren Young16 Jul 2007 04:54 
Steven Van Ingelgem16 Jul 2007 05:13 
Warren Young16 Jul 2007 05:30 
Steven Van Ingelgem16 Jul 2007 05:38 
Warren Young16 Jul 2007 06:35 
Steven Van Ingelgem16 Jul 2007 07:04 
Warren Young16 Jul 2007 07:35 
Steven Van Ingelgem16 Jul 2007 07:37 
roberto previdi16 Jul 2007 08:01 
Warren Young16 Jul 2007 09:49 
roberto previdi16 Jul 2007 10:16 
Subject:Re: Weird parsing of templated query
From:roberto previdi (hari@yahoo.it)
Date:07/16/2007 10:16:02 AM
List:com.mysql.lists.plusplus

ok i'm sorry, i supposed the bug was only in the def object. Anyway i solved the
problem like this:

mysqlpp::Query q(TheDb::Instance().getConnection()); q <<"select * from `Mob` where %0:dummy and objectId= %1:objectId ;"; q.parse(); q.def["dummy"]=1; q.def["objectId"]=3; mysqlpp::SQLQueryParms parms(&q); parms["dummy"]=1; parms["objectId"]=4; mysqlpp::Result result; cout << q.preview()<<endl; result = q.store(parms); cout << result.at(0)["objectId"];

output:

select * from `Mob` where 1 and objectId= 3 ; 4

yeah, it works!!! I love you!

I will just keep care to remove the "where %0:dummy " when there are no fields
to put in the where condition.

roby

----- Original Message ---- From: Warren Young <mysq@etr-usa.com> To: MySQL++ Mailing List <plus@lists.mysql.com> Sent: Monday, July 16, 2007 6:49:50 PM Subject: Re: Weird parsing of templated query

roberto previdi wrote:

q <<"select * from `Mob` where objectId=%0:objectId";

Single parameter queries don't work right with the SQLQueryParms mechanism. This has been discussed again and again and again and again on this list, and it's even documented. You can use the %1 workaround, or the Query streams interface.