我想在zend框架中选择具有多个条件的行,我该如何实现/
1-example“select first,firstname,lastname,city from first first = alex city = xx”; 2-example“select first,firstname,lastname,city from first first = alex 或 city = xx”;
答案 0 :(得分:1)
您可以在Zend.DB manual
中查看示例 // Build this query:
// SELECT product_id, product_name, price
// FROM "products"
// WHERE (price < 100.00 OR price > 500.00)
// AND (product_name = 'Apple')
$minimumPrice = 100;
$maximumPrice = 500;
$prod = 'Apple';
$select = $db->select()
->from('products',
array('product_id', 'product_name', 'price'))
->where("price < $minimumPrice OR price > $maximumPrice")
->where('product_name = ?', $prod);
答案 1 :(得分:1)
$firstname = 'alex';
$city = 'xx';
// AND query
$select = $adapter->select()
->from('person', array('id', 'firstname', 'lastname', 'city')
->where('firstname = ?', $firstname)
->where('city ?', $city);
// OR query
$select = $adapter->select()
->from('person', array('id', 'firstname', 'lastname', 'city')
->where('firstname = ?', $firstname)
->orWhere('city = ?', $city);
查看Zend_Db_Select
手册以查看更多示例。