gpt4 book ai didi

zend-framework - Zend框架: How to do a DB select with multiple params?

转载 作者:行者123 更新时间:2023-12-04 13:12:34 25 4
gpt4 key购买 nike

我只是想知道在Zend Framework中执行两个数据库值选择的语法是什么。示例:我想查找用户是否已经是组的成员:

$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();

最佳答案

您可以使用多个where子句,这些子句默认情况下将与在一起:

$select->from('group_members')
->where('user_id = ?', $userId)
->where('group_id = ?', $groupId);

关于zend-framework - Zend框架: How to do a DB select with multiple params?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/1844519/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com