List:MySQL++« Previous MessageNext Message »
From:Steven Van Ingelgem Date:July 16 2007 2:06pm
Subject:Re: parameters problem
View as plain text  
A vector would be ok ;) but what about named templates? Then you should
provide a map I think?


Greetz,
Steven

On 7/16/07, roberto previdi <hariseldon78@stripped> wrote:
>
> My code is something like this:
> (q is a mysqlpp::Query)
>
>
>     for(IFieldContainer::const_iterator i = toSetFields.begin(); i !=
> toSetFields.end(); i++)
>     {
>         q.def[(*i).getName()]=(*i).getValue();
>     }
>
> the query and the toSetFields vector are filled in this way (simplifying):
>
>     q << "select * from " << theTable.getName() << " where 1 ";
>     int paramIndex=0;
>     for(IFieldContainer::const_iterator i= allFields.begin(); i !=
> allFields.end(); i++)
>     {
>         if ((*i).hasValue())
>         {
>             q << " and " << (*i).getName() << "=
> %"<<paramIndex++
> <<":"<<(*i).getName();
>             toSetFields.push_back(*i);
>         }
>     }
>
> Passing a vector or a map to q.store() would be just the perfect solution
> in my opinion..
>
> Roberto Previdi
>
>
> ----- Original Message ----
> roberto previdi wrote:
> > I admit that i am one of the query.def abusers :)
>
> Father Warren has heard your confession, and bids you go and say three
> Hail Linuses.  Go forth and sin no more, my child.
>
> > The problem is that my query is dynamically generated,
>
> Please post an example of the sort of thing you're generating.  I
> suspect you might have just picked up a hammer, and all problems are
> looking like nails to you right now.
>
> > I would need something like
> > putting all the (parameter,value) couples in a vector or some dynamic
> > structure and pass it to the query object..
>
> Would it be enough if one of the overloads for these query execution
> methods took a vector of string?  Or maybe a map of string to string?
>
> Even if the answer is "yes", I'd still like to know how you're trying to
> use this feature.  I have a deep suspicion that any attempt to create
> dynamic templates is wrong-headed.  The whole idea of a "template" is
> that you have to know the parameters of the problem up front.
>
> --
> MySQL++ Mailing List
> For list archives: http://lists.mysql.com/plusplus
> To unsubscribe:
> http://lists.mysql.com/plusplus?unsub=1
>
>
>
>
>
>
> ____________________________________________________________________________________
> Pinpoint customers who are looking for what you sell.
> http://searchmarketing.yahoo.com/
>
> --
> MySQL++ Mailing List
> For list archives: http://lists.mysql.com/plusplus
> To unsubscribe:
> http://lists.mysql.com/plusplus?unsub=1
>
>

Thread
parameters problemroberto previdi16 Jul
  • Re: parameters problemWarren Young16 Jul
Re: parameters problemroberto previdi16 Jul
  • Re: parameters problemSteven Van Ingelgem16 Jul