Hi there,
It seems i use that type type of variables much more... so i found issue. Let give u example:
$s = [1 => 2, 2 => 12]; // Where 2 and 12 is some ids
$objs = \Models\ArticleAuthors::find([
'conditions' => 'article_id={article:int} AND author_id IN ({authors:array})',
'bind' => ['article' => (int)$id, 'authors' => $s]
]);
$s- they did not start from 0! If you make $s = array_values($s); to reset keys all will works fine.I think this is good to be fixed.
(i hope you did not forget that related issue too: https://github.com/phalcon/cphalcon/issues/11605)
My Phalcon version : 2.1.0r / Mar 23 2016 00:33:33 / on PHP 5.6.3 Windows
Thank You!
May the force be with you. Always
This might be PDO issue more than Phalcon's, since you're getting plain PDOException. Bound parameters should be numerical array (starting at index 0 by default).
Hmm, will accept that... but... is it possible PHQL prepare that or this is on purpose?
Im guessing this is on purpose. This could be fixed, but it would doing same stuff like array_values. And there is no really convenient way in php(or zephir) to check if assoc array is numerated from 1 or 0 etc. And even if there is one - it will add not needed overhead for this thing.
Well,
something like
if (isset($array[0])) //do something
else //don't do
You must include a unique parameter marker for each value you wish to pass in to the statement when you call PDOStatement::execute(). You cannot use a named parameter marker of the same name twice in a prepared statement. You cannot bind multiple values to a single named parameter in, for example, the IN() clause of an SQL statement.
Well, but isn't this stuff only in phalcon ? As far as i know PDO don't allow binding array like we have and phalcon just builds something like (?1, ?2, ?3) ?
You can bind in PDO like
SELECT * FROM table WHERE id = :id
$bind = ['id' => 1];
As far as I know phalcon doing the same just a bit smarter and required the param to be :id: instead of :id
I know you can bind in PDO like this. I mean we can't bind array value in PDO..... read first, then answer.
This might be a dupe of #11605
Okay then, i will close it.