代码之家  ›  专栏  ›  技术社区  ›  Alex Pliutau

Zend多个where

  •  2
  • Alex Pliutau  · 技术社区  · 14 年前

    $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();
    

    我需要提出这个问题 ... WHERE rank_id = $id AND type = 'must_sell'..

    2 回复  |  直到 11 年前
        1
  •  2
  •   Ashley    14 年前

    $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();
    
        2
  •  -3
  •   pharalia    14 年前

    以前遇到过几次这个问题。你可以这样解决

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