We have moved our forum to GitHub Discussions. For questions about Phalcon v3/v4/v5 you can visit here and for Phalcon v6 here.

DB query data binding exception

$phql = "SELECT * FROM ModelName WHERE u_id=0 AND a_id=?0";
$this->modelsManager->executeQuery($phql, [
       $a_id,
]);

This simple query always produces following error:

    The argument is not initialized or iterable()
    #0 [internal function]: Phalcon\Mvc\Model\Query->_executeSelect(Array, Array, NULL)
    #1 [internal function]: Phalcon\Mvc\Model\Query->execute()
    #2 Phalcon\Mvc\Model\Manager->executeQuery('SELECT * FROM M...', Array)

I also tried Models::find() , Models::findFirst() and Models::count(), same error occur.

I've checked $a_id is not null,but an integer.

When I do an insert query, no error happened!



85.5k

meta data cache probably


$this->di->set('modelsMetadata', function () use ($config) {

            if ($config->env === 'development') {
                return new \Phalcon\Mvc\Model\Metadata\Memory();
            }

            return new \Phalcon\Mvc\Model\MetaData\Redis([whatever]);
        }, true);

        $this->di->set('modelsCache', function () use ($config) {

            $frontCache = new FrontendData([
                "lifetime" => 186400
            ]);

            $cache = new Redis($frontCache, [whatever]);

            if ($config->env === 'development') {
                $cache->flush();
            }

            return $cache;
        });


990
edited May '17

Thank you for your reply!

I have checked, my project have enabled modelscache, and I also lookup cache keys in backend(redis),there is no cache! cache config is below:

$di->setShared('modelsCache', function () {
    return new \App\Common\Library\RedisClusterBackend();
});

I'm confused and all process are blocked!

Thanks

meta data cache probably


$this->di->set('modelsMetadata', function () use ($config) {

           if ($config->env === 'development') {
               return new \Phalcon\Mvc\Model\Metadata\Memory();
           }

           return new \Phalcon\Mvc\Model\MetaData\Redis([whatever]);
       }, true);

      $this->di->set('modelsCache', function () use ($config) {

           $frontCache = new FrontendData([
               "lifetime" => 186400
           ]);

           $cache = new Redis($frontCache, [whatever]);

           if ($config->env === 'development') {
               $cache->flush();
           }

           return $cache;
       });


5.1k
edited May '17

Hi

Can you try

$phql = "SELECT * FROM ModelName WHERE uId=0 AND aId=?0";


990

Yes, I did tried ! because I use this in a lib, without full namespace,exception thrown

Hi

Can you try

$phql = "SELECT * FROM ModelName WHERE uId=0 AND aId=?0";