Solved thread

This post is marked as solved. If you think the information contained on this thread must be part of the official documentation, please contribute submitting a pull request to its repository.

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}


372
Accepted
answer

Is this a bug?