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

Phalcon PHQL not working

I have a model App, in my controller i create the code:

$phql = "SELECT a.* FROM App a";

$app = $this->modelsManager->executeQuery($phql);
$this->view->setVar('apps', $app);

This code works, but, if i change the statement to:

$phql = "SELECT a.name_app FROM App a";

or

$phql = "SELECT a.getNameApp() FROM App a";

or

$phql = "SELECT a.getNameApp FROM App a";

not working.

In my table the column is called name_app, in my model getAppName because it is declared as protect.

Why a.name_app, a.getNameApp() or a.getNameApp not working?

error msgs:

with a.name_app

Fatal error: Call to undefined method Phalcon\Mvc\Model\Row::getNameApp()

with a.getNameApp()

Syntax error, unexpected token (, near to ') FROM App a', when parsing: SELECT a.getNameApp() FROM App a (32)

and with a.getNameApp

Column 'getNameApp' doesn't belong to the model or alias 'a', when executing: SELECT a.getNameApp FROM App a



98.9k

PHQL does not support that syntax