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 error

Hi everybody,

Below is PHQL query:

$phql = "select ar.reply_id,ar.artid,ar.reply_time,ar.second_reply,ar.reply_content,a.artname,c.cname from articlereply as ar ";
$phql .= "left join ( article as a left join category as c on a.cid=c.cid ) on ar.artid=a.artid ";
$phql .= "where ar.reply_uid=:reply_uid: order by ar.reply_time desc";

$article_reply = $this->modelsManager->executeQuery($phql,array(
    "reply_uid" => $reply_uid
));

i can use above sql running in mysql workbench,but cannot running in Phalcon,show below error:

PhalconException: Syntax error, unexpected token (, near to ' article as a left join category as c on a.cid=c.cid ) on ar.artid=a.artid where ar.replyuid=:replyuid: order by ar.replytime desc', when parsing: select ar.replyid,ar.artid,ar.replytime,ar.secondreply,ar.replycontent,a.artname,c.cname from articlereply as ar left join ( article as a left join category as c on a.cid=c.cid ) on ar.artid=a.artid where ar.replyuid=:replyuid: order by ar.replytime desc (261)



99.6k
Accepted
answer

God, why you are not using query builder ? left join ( article as a left join category as c on a.cid=c.cid ) what a hell is this join ? PHQL don't support syntax like this, just join category and then join article.

Hi ,

i have solved below PHQL query and new sql is below show:

$phql = "select ar.replyid,ar.artid,ar.uid,ar.uname,ar.parentid,ar.replyuname,ar.replycontent,a.artname,c.cname from articlereply as ar "; $phql .= "left join article as a on a.artid=ar.artid "; $phql .= "left join category as c on c.cid=a.cid "; $phql .= "where ar.parentid =:parentid: order by ar.uname,ar.replytime desc"; $articlereply = $this->modelsManager->executeQuery($phql,array( "parentid" => $parent_id ));

God, why you are not using query builder ? left join ( article as a left join category as c on a.cid=c.cid ) what a hell is this join ? PHQL don't support syntax like this, just join category and then join article.

Use query builder pls, this looks really bad :)

Hi guy,

do you have the url about learning query builder ?thanks.

Use query builder pls, this looks really bad :)