2010-09-03 40 views
2

我有THI下一個代碼,但他不工作:Zend的多個地方

$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

*不*工作是不是一個有用的描述。請說明什麼不起作用以及是否有任何錯誤。確保你確實啓用了錯誤報告。使用'assemble()'獲取組裝的查詢字符串,並將其中的第二個字段更改爲'type =「must_sell」',因爲該值不可變。 – Gordon 2010-09-03 09:33:41

回答

2

戈登在他的評論中說,類型不是一個變量:

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

我的評論並不是說這會解決問題。只是這不需要。 – Gordon 2010-09-03 10:22:57

+0

這個工程很漂亮。 – pltvs 2010-09-06 06:18:45

-3

之前遇到過這個問題幾次。你可以解決它像這樣

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

對不起,但是這會返回一個錯誤:SQLSTATE [21000]:基數衝突:1241操作數應該包含1列 – pltvs 2010-09-03 09:49:12