I've tried everything I could think of but can't get the QueryBulder to return integers when making counting queries or using partial models (FYI different than when using a full model). I've read quite a lot, and will drop a few links below 'cos that could be useful to others:
https://forum.phalconphp.com/discussion/263/binding-parameters-to-querybuilder https://github.com/phalcon/cphalcon/issues/2111 http://stackoverflow.com/questions/22084499/how-to-avoid-pdostatementbindparam-messing-with-the-referenced-value https://github.com/phalcon/cphalcon/issues/2111 http://www.php.net/manual/en/pdostatement.bindparam.php
So now, my setup: I'm on Ubuntu16, php7.0.8, mysql 5.5.44, phalcon 3.0, php-mysqlnd and I've tried a few things:
±1. I though I set up PDO with PDO::ATTR_EMULATE_PREPARES => false, PDO::ATTR_STRINGIFY_FETCHES => false... The query builder then returns numeric values, great, but the basic model features stop working (oModel->create doesn't update the pk/id, oModel->update doesn't update the DB)
±2. Tried to force bind params in the QB, but nothing:
$aParams = [ 'models' => ['client' => '\Phapp\Model\Client'], 'columns' => ['client.clientpk'], 'order' => ['client.date_created'] ]; $oQueryBuilder = $oService->modelsManager->createBuilder($aParams); $oQueryBuilder->andWhere('client.clientpk = :clientpk:', ['clientpk' => 1], ['clientpk' => \Phalcon\Db\Column::BIND_PARAM_INT]); $oQuery = $oQueryBuilder->getQuery()->execute();
but that still returns a strings.
±3. I tried to play with $oQuery->getBindParams(), $oQuery->getBindTypes() , change PDO setting on teh fly... nothing.
So I take any input/solution on this problem, because it looks like the answer end up being there (http://stackoverflow.com/questions/22084499/how-to-avoid-pdostatementbindparam-messing-with-the-referenced-value & http://www.php.net/manual/en/pdostatement.bindparam.php), in the fact we should be able to bindValues instead of bindParams.