Limiting a doctrine query with a fetch-joined collection?

Paginate was merged with doctrine 2.2 And the new symfony2 release 2.0.10 is compatible with. Now use it like that //use Doctrine paginator use Doctrine\ORM\Tools\Pagination\Paginator; Write your query then call results like that. $query->setMaxResults($limit); $query->setFirstResult($offset); $results = new Paginator($query, $fetchJoin = true); Hope this will help you. Note: If you are using SF2 2.0.10, you … Read more

Use a DATE() function in a WHERE clause with DQL

You can achieve what you want by using a custom function: use Doctrine\ORM\Query\AST\Functions\FunctionNode; use Doctrine\ORM\Query\Lexer; use Doctrine\ORM\Query\SqlWalker; use Doctrine\ORM\Query\Parser; class DateFunction extends FunctionNode { private $arg; public function getSql(SqlWalker $sqlWalker) { return sprintf(‘DATE(%s)’, $this->arg->dispatch($sqlWalker)); } public function parse(Parser $parser) { $parser->match(Lexer::T_IDENTIFIER); $parser->match(Lexer::T_OPEN_PARENTHESIS); $this->arg = $parser->ArithmeticPrimary(); $parser->match(Lexer::T_CLOSE_PARENTHESIS); } } Then registering this function in your code: … Read more