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 Result Types

Is this possible to get resultsets similar to findFirst(), but using $this->modelsManager->executeQuery(some PHQL) ?? Now I'm selecting one row and I have to use foreach ($user as $u) { echo $u->email; } instead echo $user->email; to echo one email.



40.8k
Accepted
answer
edited Mar '14

Hi, try this:

class IndexController extends BaseController
{
    public function indexAction()
    {
        $phql = "SELECT * FROM Users WHERE id=1";
        $user = $this->modelsManager->executeQuery($phql)->getFirst();

        echo $user->email;
    }
}


29.8k

Thank you, that's it