Inner Join in PHQL

Hello everybody,

I want to use this SQL Query :

SELECT DISTINCT name,picture FROM Bar AS b INNER JOIN Beer AS be ON b.id = be.idBar AND be.day = :day;

in my application :

$bars = $app->modelsManager->executeQuery($phql, array( 'day' => $day ));

But I get this error:

Uncaught exception 'Phalcon\Mvc\Model\Exception' with message 'Syntax error, unexpected token COLON, near to 'day;', when parsing: SELECT DISTINCT name,picture FROM Bar AS b INNER JOIN Beer AS be ON b.id = be.idBar AND be.day = :day;

Does anybody has an idea what the problem could be?

Bruno

Placeholders in PHQL require two colons:

$phql = "SELECT DISTINCT name,picture FROM Bar AS b INNER JOIN Beer AS be ON b.id = be.idBar AND be.day = :day:";

If you want to use plain SQL queries, you can use Phalcon\Db: http://docs.phalconphp.com/en/latest/reference/db.html#finding-rows



2.8k

Thank You