Reputation: 21
$submodules = Modules::find(
array(
'moduleid in (:mods:) and parentid = :parentid:',
'bind' => array(
'mods' => '1,2',
'parentid' => 1
),
'bindtype' => array(
'mods' => Column::BIND_PARAM_STR,
'parentid' => Column::BIND_PARAM_INT
)
)
);
I hope the sql that is "select * from modules where moduleid in (1,2) and parentid = 1" but result is not correct.
help plz.
Upvotes: 2
Views: 3535
Reputation: 2699
Escaping :mods: will produce '1,2' therefore: select * from modules where moduleid in ('1,2') and parentid = 1
You need to use a bound parameter for every value in the "in":
$submodules = Modules::find(array(
'moduleid in (:firstMod:, :secondMod:) and parentid = :parentId:',
'bind' => array(
'firstMod' => 1,
'secondMod' => 2,
'parentId' => 1
)
));
In this case is better use the QueryBuilder
Upvotes: 1