We have moved our forum to GitHub Discussions. For questions about Phalcon v3/v4/v5 you can visit here and for Phalcon v6 here.

Is that a bug?

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) .")")
edited Nov '15

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.



59.9k

Hi Nikolay and Jurigag,

i am using the version 2.0.6, so it should run. Ok now i understand the point .*, but it doesn't run at all.

Rgds

Stefan

Show us code, I wrote it like this and its working fine.



59.9k

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

You sure you have good version? Maybe for some reason it's not working on 2.0.6, I'm using 2.0.7 or 8 and its fine, in query it should just build ('1,2,3,13')

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?

Yea it's maybe of php version too, I'm on 5.6 and 2.0.7 and its fine. In all using cases passing array as bind param works.



59.9k

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



93.7k
Accepted
answer

Just download latest version dll and try again :)

Yea you see, there shouldnt be any problem :D



59.9k

No Jurigag there is no problem now :-)

And i installed phalcon 2.0.8 and my project is working awesome now, even with my code above :-)))))))

Thank you al, there's no bug



2.7k

Thanks. I was having the same issue. :)

Just download latest version dll and try again :)