Zend Framework:如何使用多个参数进行数据库选择?
我只是想知道在 Zend Framework 中执行 db select 的语法是什么,其中两个值为 true。示例:我想查找用户是否已经是某个组的成员:
$userId = 1;
$groupId = 2;
$db = Zend_Db_Table::getDefaultAdapter();
$select = new Zend_Db_Select($db);
$select->from('group_members')
->where('user_id = ?', $userId); //Right here. What do I do about group_id?
$result = $select->query();
$resultSet = $result->fetchAll();
I'm just wondering what the syntax is to do a db select in Zend Framework where two values are true. Example: I want to find if a user is already a member of a group:
$userId = 1;
$groupId = 2;
$db = Zend_Db_Table::getDefaultAdapter();
$select = new Zend_Db_Select($db);
$select->from('group_members')
->where('user_id = ?', $userId); //Right here. What do I do about group_id?
$result = $select->query();
$resultSet = $result->fetchAll();
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
您可以使用多个 where 子句,默认情况下这些子句将通过 AND 组合在一起:
You can use multiple where clauses which will be ANDed together by default:
以防万一有人想要向具有多个参数的选择添加 OR 条件
有关更多信息,请查看 Zend Select 手册 文档:zend.db.select
Just In case someone wants to add an OR condition to a select with multiple params
For more view the Zend Select manual Docs: zend.db.select