在zend框架中使用where where获取数组

0 zend-framework

如何获取catid ="someid"的数组?

我试过这个,但没有奏效

public function findCatArr($catid)
{
    $select = $this->getDbTable()->select();
    $select->setIntegrityCheck(false);
    $select->from('photo',array('id','catid','pic','desc'
    ))->where("catid"." LIKE '%".$catid."%'");
    $row = $this->getDbTable()->fetchAll($select);


    if (0 == count($row)) {
        return;
    }else{

        return $row->toArray();


        }   
    }
Run Code Online (Sandbox Code Playgroud)

Tim*_*ain 6

我想你想要:

->where('catid = ?', $catid);
Run Code Online (Sandbox Code Playgroud)

如果你真的想做一个LIKE搜索,那么它是:

->where('catid LIKE ?', '%'.$catid.'%');
Run Code Online (Sandbox Code Playgroud)

但只有在需要时才使用它,因为LIKE搜索比直接索引查找慢得多.

如果$catid是一个ID数组,那么这应该工作:

->where('catid IN (?)', $catid);
Run Code Online (Sandbox Code Playgroud)