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

Query builder can't parse where condition

Hi! I have a simple piece of code:

        $email = '[email protected]';
        $qb = $this->modelsManager->createBuilder();
        $qb->addFrom('App\Model\User', 'a');
        $qb->where('a.email = :email', ['email' => $email]);
        $qb->getQuery()->execute();

Result: Phalcon\Mvc\Model\Exception: Scanner: Unknown opcode 58

When I provide email like below:

$qb->where('a.email = "[email protected]"');

It seems to work. Is there anything in phalcom ORM what might be useful?

Edit: OK, my fault, I haven't noticed that DOUBLE colon is required like :email: what is really unusual



77.7k
Accepted
answer

PHQL syntax requires both left and right colon for paramter placeholders:

        $qb->where('a.email = :email:', ['email' => $email]);

You can mark the thread as solved now :)