I use a char array and not a std::string. Should that make a difference?
>From: "Samuel Borgman" <samuel.borgman@stripped>
>To: "Bjoern Rasmussen" <bjoern_rasmussen@stripped>
>Subject: Re: Escaping a string
>Date: Fri, 31 Mar 2006 11:12:40 +0100 (CET)
>
>Hey,
>
>Is var.value a std::string? Or someother string? I remember having the
>same kind of trouble with my own string class(I think it was). Have you
>tried with .c_str()?
>
>/Samuel
>
> > 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
> >
> >
> >
> > --
> > MySQL++ Mailing List
> > For list archives: http://lists.mysql.com/plusplus
> > To unsubscribe:
> > http://lists.mysql.com/plusplus?unsub=1
> >
>
>