2010-09-03 37 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