0

What's the correct syntax to select multiple rows through an array using Zend ? So basically fetch all the data that has name $a OR $b etc..depending on number of array elements. I can't figure it out.......

public function selectRow($array) 
{
    $data = $this->table->select()
                        ->where('name = ?', $array);
    return $this->table->fetchAll($data);
}
Nandakumar V
  • 4,317
  • 4
  • 27
  • 47
michael liu
  • 55
  • 1
  • 7

2 Answers2

1

you can use orWhere() in the Zend_Db_Select. Check the manual Zend_Db_Select::where().

public function selectRow($array) 
{
    $data = $this->table->select()
                        ->where('name = ?', $array)
                        ->orWhere('address = ?', $anotherarray);
    return $this->table->fetchAll($data);
}
  • it would be better to use IN and NOT IN when the where condition contains array of values
Nandakumar V
  • 4,317
  • 4
  • 27
  • 47
1

You have to use IN clause for that. So try,

$data = $this->table->select()
                    ->where('name IN (?)', $array);
Rikesh
  • 26,156
  • 14
  • 79
  • 87