Cakephp IN条件绕过重复ID's获取数据


Cakephp IN condition bypass duplicate ID's to fetch data

我使用这个代码片段应用条件从数据库

获取数据
array( 'Account.type_id' => $account_type_id_ids );

其中$account_ids例如为{3,10}。I am passing through

Array
(
    [0] => 3
    [1] => 10
)

但是在accounts表中有多个行包含这些ID

:

id    | type_id
1     |    2
2     |    3
3     |    2
4     |    3
5     |    10

所以这里必须是fetchrows {2,4,5}但是当我print_r这个数据时我得到的是一个只有{2,5}的列表我想取回这三个

如果你使用的是cakephp 2.6,请试试这个

array( 'Account.type_id IN' => "'.$account_type_id_ids.'" );