[英]Select Zend Db with array
What's the correct syntax to select multiple rows through an array using Zend ? 使用Zend通过数组选择多行的正确语法是什么? So basically fetch all the data that has name
$a OR $b
etc..depending on number of array elements. 所以基本上获取所有名称
$a OR $b
等的数据。取决于数组元素的数量。 I can't figure it out....... 我无法弄明白.......
public function selectRow($array)
{
$data = $this->table->select()
->where('name = ?', $array);
return $this->table->fetchAll($data);
}
you can use orWhere()
in the Zend_Db_Select. 你可以在Zend_Db_Select中使用
orWhere()
。 Check the manual Zend_Db_Select::where() . 检查手册Zend_Db_Select :: where() 。
public function selectRow($array)
{
$data = $this->table->select()
->where('name = ?', $array)
->orWhere('address = ?', $anotherarray);
return $this->table->fetchAll($data);
}
IN
and NOT IN
when the where condition contains array of values IN
和NOT IN
You have to use IN clause
for that. 你必须使用
IN clause
。 So try, 所以试试吧,
$data = $this->table->select()
->where('name IN (?)', $array);
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.