我正在使用此代码片段应用条件从数据库中获取数据
array( 'Account.type_id' => $account_type_id_ids );
例如,$account_ids 是 {3,10}。 我正在路过
Array
(
[0] => 3
[1] => 10
)
但是在 accounts 表中有多个带有这些 ID 的行
喜欢:
id | type_id
1 | 2
2 | 3
3 | 2
4 | 3
5 | 10
所以这必须是获取行 {2,4,5} 但是当我 print_r 这个数据时,我得到了一个只有 {2,5} 的列表 我想获取所有这三个
最佳答案
如果您使用的是 cakephp 2.6,请尝试这个
array( 'Account.type_id IN' => "'.$account_type_id_ids.'" );
关于php - Cakephp IN 条件绕过重复 ID 来获取数据,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32374723/