Re: DB->quote

From: Date: Thu, 23 Aug 2001 13:12:43 +0000
Subject: Re: DB->quote
References: 1  Groups: php.pear.dev 
Request: Send a blank email to pear-dev+get-1672@lists.php.net to get a copy of this message
[Edin Kadribasic <ek@proventum.net>] > On Wed, 22 Aug 2001, Tomas V.V.Cox wrote: > > > Edin Kadribasic wrote: > > > > > > I just checked out the lates php CVS just to find that all of my > > > applications that are using Pear::DB were broken due to a change in > > > quoteString method. > > > > > > The problem is that the new quote() method retuns a string with single > > > quotes around it which I think it's a very bad idea. > > > > > > > > > Even the function stub says: > > > > > > "Quote the given string so it can be safely used *within* string > > > delimiters" > > > > > > It does not say anything about putting those delimiters within the returned > > > string. Any reason for this change? > > > > > > > There were a long thread here about the quote system and ended with this > > option. Is the standar selected by others database abstraction layers > > like Perl DBI and will put the single quotes only when needed. > > > > old method (select by hand when to put single quotes): > > $sql = "insert into foo values ('" . $db->quoteString($name) . > > "')"; > > new method (automatic put single quotes when needed): > > $sql = "insert into foo values (" . $db->quote($name) . ")"; > > You realize that having "old method" and "new method" in a minor revision > change of PHP means breaking backwards compatiblity of every single PHP > script that uses quoteString() method. It will require major effort on > developers part to make their applications work again. It also makes > writting PHP code version dependant. > > I suggest that either: > > 1. method quoteString() disappears from DB/common.php since its inline > documentation is misleading "(preserved for compatibility issues)" > > 2. method quoteString() is changed to > > return substr($this->quote($string),1,-1); > > which would be backward compatible. I have to agree, [2] would be the best option. We shouldn't break compatibility without a good reason. - Stig -- Stig Sæther Bakken <ssb@alltheweb.com> Fast Search & Transfer ASA, Trondheim, Norway

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