2009年8月27日星期四

Re: [fw-db] Not sure, but is this a bug?

>From what I saw, it simply takes any ? and introduces another string but
quoted with for SQL (using ''), without any specification if the question
mark can or not be the first character.

The provided code in the documentation shows:

* <code>
* $text = "WHERE date < ?";
* $date = "2005-01-02";
* $safe = $sql->quoteInto($text, $date);
* // $safe = "WHERE date < '2005-01-02'"
* </code>

If the text is not "WHERE date < ?", but rather a simple "? > date" which
will be inserted into the WHERE section after that, it wouldn't work.

Anyway, since I have little experience using ZF, I can't assure of a bug in
here, so I will just leave the thread =) If it's a bug, I will be glad to
have helped in such a little thing, else, I'm sorry hehehe.


Thasmo wrote:
>
> Maybe that's right, in this case I guess,
> it won't affect anything, as the '?'-sign won't
> ever be at position 1, as long as I understand the quote function.
>
> Anyone there to test it?
>
>
> Mamsaac schrieb:
>> I'm not really looking into trying the code, since I was just reading
>> some of
>> the Db code for entertaining (hey! it's better than some bad novels =) ).
>>
>> I came up with this part in class Zend_Db_Adapter_Abstract:
>>
>> public function quoteInto($text, $value, $type = null, $count = null) {
>> if ($count === null) {
>> return str_replace('?', $this->quote($value, $type), $text);
>> } else {
>> while ($count > 0) {
>> if (strpos($text, '?') != false) {
>> $text = substr_replace($text, $this->quote($value),
>> strpos($text, '?'), 1);
>> }
>> --$count;
>> }
>> return $text;
>> }
>> }
>>
>> My issue, and I'm probably wrong, but this shouldn't take long, is that I
>> believe that strpos($text, '?') != false should be strpos($text, '?') !==
>> false
>>
>> If the "?" is the first character, it would just not replace it. (I mean,
>> ?
>> being in position 0).
>>
>> If I'm wrong, I apologize for taking a quick reaction without
>> verifying...
>> but I don't have any applications of mine using the ZF (again, I was just
>> reading :D) and I'm not supposed to waste too much time =)
>>
>> And if this is not the right place to ask about this, again, sorry =)
>>
>>
>
>

--
View this message in context: http://www.nabble.com/Not-sure%2C-but-is-this-a-bug--tp25178000p25180965.html
Sent from the Zend DB mailing list archive at Nabble.com.

没有评论: