Hi,
in my last discussion i had a problem with find() bind parameter, maybe it is a bug here:
https://forum.phalcon.io/discussion/9573/multiple-find-array-parameters
Rgds
Stefan
|
Nov '15 |
9 |
386 |
0 |
Hi,
in my last discussion i had a problem with find() bind parameter, maybe it is a bug here:
https://forum.phalcon.io/discussion/9573/multiple-find-array-parameters
Rgds
Stefan
Mysql IN clause uses comma separated values, like so:
IN(1,2,3,4)
So i dont think you can pass an array to inWhere clause (correct me if im wrong);
You can do something like:
->andWhere("type IN ('virtual', 'mechanical')");
Or in your case something like:
->andWhere("id IN (". implode(',', $idsArray) .")")
You dont have to implode etc, its just should work with param IN ({bindednParamName:array}). Maybe you have wrong phalcon version?
Its working both with modelsManager, find and query static function, example code:
$cars = Car::query()
->andWhere('id IN ({car:array})',array('car'=>[194,195]))
->execute();
Also this point in SELECT [Vokuro\Models\Users]. is not bug at all, its just telling to select all columns from Users class like in normql SQL lke users. all columns from table users.
Hi Jurigag,
This is my array name:
$wantedUsersId
This is my array content:
Array ( [0] => 1 [1] => 2 [2] => 3 [3] => 13 )
This is my code:
$users = Users::find(
array(
'id IN ({ids:array})',
'bind' => array(
'ids' => $wantedUsersId
)
)
);
I get an error:
Scanning error before 'ids:array})' when parsing: SELECT [Vokuro\Models\Users].* FROM [Vokuro\Models\Users] WHERE id IN ({ids:array}) (83)
Do you have an idea for that?
Rgds
Stefan
Hello @Stefjoe , ive tried exactly your code and it works fine. Im guessings its version problem since im using Version 2.0.7, and you said above that you have 2.0.6
Also whats your php version, mine is 5.6?
Hi,
sorry, sorry, sorry guys. I have phalcon 2.0.3 on my Windows machine where my project is running and phalcon 2.0.6 on my Mac :-/ I was confused with the versions.
But i checked my php version it is 5.6.8 on xampp, could it be a problem to implement phalcon 2.0.8?
I am so sorry, forgive me. That's embarrassing :-)
Rgds
Stefan
Thanks. I was having the same issue. :)
Just download latest version dll and try again :)