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

Possible bug with modelsManager::createQuery()

I have some code that creates a query once with:

$Query = $this->di('modelsManager')->createQuery($phql);//ignore $this->di(), that's custom, unrelated code

I then loop through an array, substituting in a bound parameter each loop, and re-executing the query like this:

$Result = $Query->execute(['location'=>$location_id]);

where $location_id is different on every execution.

This code has worked for years - or rather, there have been no reports of any ill consequences from it not working.

I updated to v3.4.4 at the end of August, and it seems now that only the first binding sticks. Subsequent loops result in the same query being run as the first loop. So 10 iterations will result in the first query being run 10 times. I can confirm this by looking at the query log for my MariaDB server.

Has anyone else encountered this issue?

edited Oct '19

Same here.

I've used a code like that (only with createBuilder), but had to re-build the query every time, even though only the params changed.

Version => 3.4.4
Build Date => Jun 30 2019 21:28:23

PHP 7.2.22

I think it also affects the reusable option in relations

@lajosbencz Did you encounter this bug with earlier versions or just with 3.4.4? I jumped from 3.4.1 to 3.4.4 and don't recall this happening with 3.4.1.

I think we were on v3.1 before upgrading to 3.4