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 error

What is wrong with this query? I get the error: Scanning error before 'Apponte\Models\E...' when parsing: SELECT a.id, a.label, a.link, Deriv1.Count FROM Apponte\Models\Entities\Menu a LEFT OUTER JOIN (SELECT parent, COUNT(*) AS Count FROM Apponte\Models\Entities\Menu GROUP BY parent) Deriv1 ON a.id = Deriv1.parent where id=5 (226)

        $query = new Query("SELECT a.id, a.label, a.link, Deriv1.Count FROM `Apponte\Models\Entities\Menu` a  LEFT OUTER JOIN (SELECT parent, COUNT(*) AS Count FROM `Apponte\Models\Entities\Menu` GROUP BY parent) Deriv1 ON a.id = Deriv1.parent where id=5", $this->getDI());
        // Execute the query returning a result if any
        $menu = $query->execute();


98.9k
Accepted
answer

This syntax is not supported in PHQL

What's the better way to do complex queries?