views:

37

answers:

2

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

I need to make this query ... WHERErank_id= $id ANDtype= 'must_sell'..

Thank toy.

A: 

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')");
pharalia
Sorry, but this returns a error:SQLSTATE[21000]: Cardinality violation: 1241 Operand should contain 1 column
Alexander.Plutov
+1  A: 

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();
Ashley
My comment wasnt to suggest that this would solve the issue though. Just that it's unneeded.
Gordon
This works pretty.
Alexander.Plutov