List:MySQL++« Previous MessageNext Message »
From:Chris Frey Date:April 11 2005 3:19am
Subject:Re: Mysql++ && printf
View as plain text  
On Sun, Apr 10, 2005 at 07:47:52PM -0700, timothy johnson wrote:
> What about using vars in the query line?
> 
> query << "SELECT * FROM table WHERE id=" . var;
> this way didnt work
> 
> sprintf(query. "SELECT * FROM table WHERE id=%i". var);
> nor did this way work.

This is C++, not PHP or perl.

query << "SELECT * FROM table WHERE id=" << var;

If you're building SQL from scratch, make sure you quote properly as well.
Going from memory, I think you use the quote manipulator like this,
but I could be wrong, I don't use it regularly:

query << "SELECT * FROM table WHERE id=" << quote << var;

- Chris

Thread
Mysql++ && printftimothy johnson6 Apr
  • Re: Mysql++ && printfChris Frey6 Apr
    • Re: Mysql++ && printftimothy johnson11 Apr
      • Re: Mysql++ && printfChris Frey11 Apr
        • Re: Mysql++ && printfWarren Young12 Apr