I'm sure I was over thinking this. I ultimately went with this:
$selectObj->where("name LIKE ?", '%' . $var . '%' );
It works fine but I still think it would be nice if the adapter had a
simple escape method rather than just quote methods.
Mark
On Tue, Jul 14, 2009 at 11:43 AM, till<[email protected]> wrote:
> On Tue, Jul 14, 2009 at 7:33 PM, Mark Wright<[email protected]> wrote:
>> I want to insert a variable into a LIKE query using zend_db_statement
>> but I'm not sure how to do this correctly. This doesn't work:
>>
>> $selectObj->where("name LIKE '%?%'", $var );
>>
>> It gives you "name LIKE '%'some text'%'". I can do this:
>>
>> $selectObj->where("name LIKE ?", '%' . $var . '%' );
>>
>> What I really want would be something like this:
>>
>> $selectObj->where("name LIKE '%" . $adapter->escape($var) . "%'");
>
> That would never work. That's like doing:
>
> $foo->where("name = 'hello ?', 'world'); // 'hell 'world''
>
> The % are part of the value. Can't you do the following?
>
> $foo->where("name LIKE ?', '%' . $var . '%');
>
> Till
>
--
Have fun or die trying - but try not to actually die.