List:MySQL++« Previous MessageNext Message »
From:Bjoern Rasmussen Date:March 31 2006 10:01am
Subject:Escaping a string
View as plain text  
Hi there

I've just started using the MySQL++ library and has run into trouble when I 
escape strings. Consider the query below where column "foo" is a string and 
column "bar" is an int:

  mysqlpp::Query query = con_.query();
  query << "INSERT INTO foobar(foo, bar) ";
  query << "VALUES (";
  query << quote << var.value << ", ";
  query << 123 << ", ";
  query << ")";

If var.value is a non-empty string it is escape and quotes are inserted to 
show it's a string but if var.value is an empty string no quotes are put to 
show it's a string. In other words when var.value is empty the query string 
will look like:

INSERT INTO foobar(foo, bar) VALUES( , 123)

Which is invalid syntax. How am I supposed to escape strings which can be 
empty?

Regards

Bjoern


Thread
Escaping a stringBjoern Rasmussen31 Mar
Re: Escaping a stringBjoern Rasmussen31 Mar
  • Re: Escaping a stringWarren Young31 Mar
    • Re: Escaping a stringSamuel Borgman31 Mar
      • Re: Escaping a stringWarren Young31 Mar
        • Re: Escaping a stringSamuel Borgman31 Mar
          • Re: Escaping a stringWarren Young5 Apr