2009年1月31日星期六

[fw-db] question about using a like statement in a select

I'm having a problem using quoting and a like statement with somehting like this:
<?php
class Query extends Zend_Db_Table{
   
    public function getMenuResults($query){
        $sql="select id, headline, body from node where body like '%".$this->_db->quote($query)."%'";
        echo $sql."<br/>";
       //outputting: select id, headline, body from node where body like '%'some'%'

with problem being inner single quotes.

Is there a way to call quote without it putting the surrounding single quotes. This is actually a larger issue (and I'd probably consider a bug for things like 'select * from menu where id=23' where adding a set of single quotes around 23 adds time to query processing on MySQL.

I don't want to get into the syntax of ZF's select statement as I don't see much advantage to it to writing straight SQL.

thanks,

jonathan



没有评论: