这将是为您提供指定括号的“官方”方式(请参见
Zend_Db_Select文档中的示例20
):
$a1 = 'one';$a2 = 'two';$select->from('product');$select->where('status = ?', $status);$select->where("attribute = $a1 OR attribute = $a2");因此,鉴于您不知道自己提前拥有多少个属性,因此您所做的事情似乎很合理。

这将是为您提供指定括号的“官方”方式(请参见
Zend_Db_Select文档中的示例20
$a1 = 'one';$a2 = 'two';$select->from('product');$select->where('status = ?', $status);$select->where("attribute = $a1 OR attribute = $a2");因此,鉴于您不知道自己提前拥有多少个属性,因此您所做的事情似乎很合理。