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

PHQL not support number number prefix field name?

Case 1:

$phql = "select SUM(1th_interval_count) from Test\Models\Device";
$device = $this->modelsManager->executeQuery($phql);
var_dump($device->toArray());

result:

array (size=1)
  0 => 
    array (size=1)
      'th_interval_count' => string '2' (length=1)

Case 2:

$phql = "select SUM(1th_interval_count) from Test\Models\Device";
$device = $this->modelsManager->executeQuery($phql);

show exception:

Syntax error, unexpected token IDENTIFIER(th_interval_count), near to ') from Test\Models\Device', when parsing: select SUM(1th_interval_count) from Test\Models\Device (54)
#0 [internal function]: Phalcon\Mvc\Model\Query->parse()
#1 [internal function]: Phalcon\Mvc\Model\Query->execute(NULL)
#2 D:\dev\UI\ccon_ap\apps\Test\controllers\ModelsController.php(36): Phalcon\Mvc\Model\Manager->executeQuery('select SUM(1th_...')
#3 [internal function]: Test\Controllers\ModelsController->sqlAction()
#4 [internal function]: Phalcon\Dispatcher->dispatch()
#5 D:\dev\UI\ccon_ap\public\index.php(45): Phalcon\Mvc\Application->handle()
#6 {main}


535
Accepted
answer

Is this a bug?