-
-
Notifications
You must be signed in to change notification settings - Fork 2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[BUG] Phalcon\Mvc\Model\Query\Builder error if using mixed integer and string placeholder #701
Comments
This behavior is produced by array_merge: $x = array_merge(array(1=>2, 2=>1), array('minprice' => '70000000'));
print_r($x); Produces: Array ( [0] => 2 [1] => 1 [minprice] => 70000000 ) |
I see. |
The '+' does not merge elements: print_r(array(1 => "hello", 2 => "hola") + array(2 => "hi", "minprice" => 700)); Produces: Array
(
[1] => hello
[2] => hola
[minprice] => 700
) It seems we need to create our own 'merge' function to fix this. |
print_r( array(2 => "hi", "minprice" => 700) + array(1 => "hello", 2 => "hola") ) Produces: Array(
[2] => hi
[minprice] => 700
[1] => hello
) That's what we need, right? |
No, note that the value in '2' is still 'hi' if you pass a new value for '2' like in your example 'hola', the value must be replaced/merged because you don't want the old one 'hi' anymore |
@phalcon, what I mean is we can accomplish merge and replace with '+' operator by flipping the new array to the left operand. |
Fixed by @sjinks, thanks! |
Phalcon\Mvc\Model\Query\Builder error if using mixed integer and string placeholder. It only happen when the integer placeholder is not starting from zero.
In my case I added the string placeholder using andWhere. The sql output: SQLSTATE[HY093]: Invalid parameter number: parameter was not defined
After I debuged, It turns out that the array keys of the integer placeholder in __bindParams has changed.
Example in my project:
Before andWhere
after $builder->andWhere('ad.price >= :minprice:', ['minprice'=>$x['minprice']]);
Notice that the _bindParams keys has changed
The text was updated successfully, but these errors were encountered: