开发者

Zend multiple where

开发者 https://www.devze.com 2023-01-14 02:19 出处:网络
I have thi next code, but he doesn\'t work: $select_sell = $this->select(); $select_sell->from($this->_name, array(\'rank_id\'))

I have thi next code, but he doesn't work:

$select_sell = $this->select();
$select_sell->from($this->_name, array('rank_id'))
            ->where('rank_id = ?', $id)
            ->where('type = ?', 'must_sell');
$result = $this->fetchAll($select_sell)-&开发者_运维技巧gt;count();

I need to make this query ... WHERE rank_id = $id AND type = 'must_sell'..

Thank toy.


As gordon said in his comment, type isn't a variable:

$select_sell = $this->select();
$select_sell->from($this->_name, array('rank_id'))
            ->where('rank_id = ?', $id)
            ->where('type = "must_sell"');
$result = $this->fetchAll($select_sell)->count();


Run into this problem a few times before. You can solve it like this

$select_sell = $this->select();
$select_sell->from($this->_name, array('rank_id'))
    ->where("(rank_id = $id AND type = 'must_sell')");
0

精彩评论

暂无评论...
验证码 换一张
取 消