Re: Quote String

From: Date: Sun, 15 Jul 2001 15:07:32 +0000
Subject: Re: Quote String
References: 1 2  Groups: php.pear.dev 
Request: Send a blank email to pear-dev+get-782@lists.php.net to get a copy of this message
Paul DuBois wrote: > > At 11:19 AM +0200 7/3/01, Tomas V.V.Cox wrote: > >Sorry for not to follow the thread but I recently have suscribed to the > >list. Please test this patch to the pear/DB/mysql.php, so if works I'll > >commit the change to the quote string behavoir. The same for the sybase > >extension. > > > >For the question about null values I don't see any way for inserting > >them, but the needed change in executeEmulateQuery() for supporting it > >is trivial. What do you think to add the unquoted NULL string when the > >null (constant) value is given? > > Personally, I think that's the corrrect behavior. But on the other hand, > it wouldn't be so difficult to make quoteString() do that to, such that: > > quoteString("a") => "'a'" > quoteString (null) => "NULL" > > The intent of quoteString is to return a value that can be added to > a query string. This would allow you to do so more generally without > having to write stuff like: > > $query = "INSERT INTO tbl_name SET col_name = " > . ($x == null ? "NULL" : $conn->quoteString ($x)); > > Instead, you'd just write: > > $query = "INSERT INTO tbl_name SET col_name = ". $conn->quoteString ($x); > > That's how the quote() method in DBI works. (Am I allowed to say that > here? :-) Yes you are. :-) It's no big secret that PEAR DB is much inspired by DBI. - Stig

« previous php.pear.dev (#782) next »