On Tue, Jul 14, 2009 at 7:43 PM, 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''
>
Sorry, typo in the above. But it doesn't make sense anyway. ;-)
> The % are part of the value. Can't you do the following?
>
> $foo->where("name LIKE ?', '%' . $var . '%');
That's supposed to be:
$foo->where("name LIKE ?", '%' . $var . '%');
Apologies for the typos.
Till