php - MySql query works but syntax error in DQL -
this query in mysql gives me result want:
select reportcolumn.name report left join reportcolumn on report.id=reportcolumn.reportid report.title = "report"
however, when try write dql, syntax error.
$report = "reportname"; $statement = 'select c.name'; $statement .= ' acmedatabundle:report r'; $statement .= ' left join acmedatabundle:reportcolumn c'; $statement .= ' on r.id=c.reportid'; $statement .= ' r.title = :title'; $em = $this->getdoctrine()->getmanager(); $query = $em->createquery($statement) ->setparameters(array( 'title'=> $report, )); $data = $query->getarrayresult();
how should handling "on" part of statement. relationship defined, if leave part of statement out, wrong results.
thanks, manisha
acmedatabundle:report acmedatabundle:reportcolumn
should be
acmedatabundle.report acmedatabundle.reportcolumn
unless these real table names in case need quote table names backquotes.
Comments
Post a Comment