We are moving our forum in GitHub Discussions. For questions about Phalcon v3/v4 you can visit here and for Phalcon v5 here.

Solved thread

This post is marked as solved. If you think the information contained on this thread must be part of the official documentation, please contribute submitting a pull request to its repository.

PHQL binding array with the IN operator


I'm new to phalcon and i have been searching the forums and googling around but i have no clue if using the IN operator and binding an array can be done:

SomeModel::count(array( 'someField IN ?0', 'bind' => array('1') ));

When this code is executed (from a CLI app) i get the following message "Syntax error, unexpected EOF" and nothing on the apache error log

Am i doing something wrong or is this syntax not supported yet?

edited Apr '14

PDO does not allow to bind an array as a bound parameter only strings, booleans, integers and null are supported: http://www.php.net/manual/en/pdo.constants.php



edited Apr '14

Ok, so this seems to be more of a PDO issue, Also i would like to note that if i change the someField IN ?0 for someField = ?0 I get the PDO Error, but with IN only the Syntax error, unexpected EOF.

And thanks for the quick answer.

workaround: http://stackoverflow.com/questions/8991688/pdo-in-array-statement-and-a-placeholder

$phql = "SELECT * FROM Some\Robots WHERE id IN ({PARAM0:array})"; $robots = $modelsManager->executeQuery($phql, [ 'PARAM0' => [1, 2, 3] ]);

Update: it's supported in Phalcon 2.0.4: https://blog.phalcon.io/post/phalcon-2-0-4-released