phalcon subquery

$query = $this->modelsManager->createQuery("SELECT * FROM product p WHERE cid > 1 AND (SELECT COUNT(*) FROM product p1 WHERE p1.cid = p.cid AND p.id <= p1.id) <= 4 ORDER BY p.id DESC");
return $query->execute();
Syntax error, unexpected token SELECT, near to ' COUNT(*) FROM product p1 WHERE p1.cid = p.cid AND p.id <= p1.id) <= 4 ORDER BY p.id DESC', when parsing: SELECT * FROM product p WHERE cid > 1 AND (SELECT COUNT(*) FROM product p1 WHERE p1.cid = p.cid AND p.id <= p1.id) <= 4 ORDER BY p.id DESC (138)

I want run subquery ........ help me.

SELECT * FROM product p WHERE cid > 1 AND (SELECT COUNT(*) FROM product p1 WHERE p1.cid = p.cid AND p.id <= p1.id) <= 4 ORDER BY p.id DESC


83.4k

Phalcon does not support subqueries right now. You can use left/right/inner joins instead.

inb4: it would be great that Phalcon support subqueries

Rinalds Uzkalns did find a workaround:

http://forum.phalconphp.com/discussion/1082/sneaking-in-subqueries-into-phql#C4020

With 2.0 it could be easier to add subqueries, the thing is the parser is still in C..