protected function setLimitOrder(QueryBuilder $query, array $options)
    {
        if (isset($options['order'])) {
            $query->orderBy($options['order'], isset($options['direction']) ? $options['direction'] : null);
        }
        if (isset($options['limit'])) {
            $query->setMaxResults((int) ($options['limit']));

            if (isset($options['offset'])) {
                $query->setFirstResult((int) ($options['offset']));
            }
        }
    }
protected function setLimitOrder(QueryBuilder $query, array $options)
    {
        if (isset($options['order'])) {
            $query->orderBy($options['order'], isset($options['direction']) ? $options['direction'] : null);
        }
        if (isset($options['limit'])) {
            $query->setMaxResults((int) ($options['limit']));

            if (isset($options['offset'])) {
                $query->setFirstResult((int) ($options['offset']));
            }
        }
    }
protected function setLimitOrder ( QueryBuilder $ query , array $ options ) { if ( isset ( $ options [ 'order' ] ) ) { $ query -> orderBy ( $ options [ 'order' ] , isset ( $ options [ 'direction' ] ) ? $ options [ 'direction' ] : null ) ; } if ( isset ( $ options [ 'limit' ] ) ) { $ query -> setMaxResults ( ( int ) ( $ options [ 'limit' ] ) ) ; if ( isset ( $ options [ 'offset' ] ) ) { $ query -> setFirstResult ( ( int ) ( $ options [ 'offset' ] ) ) ; } } }
Conditionally add LIMIT and ORDER BY to a QueryBuilder query.

@param QueryBuilder $query
@param array        $options Additional options:
- 'limit' (integer):     Maximum number of results to return
- 'order' (string):      Field to order by
- 'direction' (string):  ASC or DESC
- 'contentid' (integer): Filter further by content ID
- 'id' (integer):        Filter by a specific change log entry ID
Conditionally add LIMIT and ORDER BY to a QueryBuilder query .