Using the paginator if you pass in empty query conditions it breaks the query.
$queryOptions = array();
// code to build $order, based on posted results from form
$queryOptions["order"] = $order;
// code to build $conditions, based on posted results from form
$queryOptions["conditions"] = $conditions;
$paginator = new \Phalcon\Paginator\Adapter\Model(
array(
"data" => $robot->getParts($queryOptions),
"limit" => 10,
"page" => $this->request->getQuery('p', 'int')
)
);
$order
is always empty or valid SQL ("id DESC" or "id DESC, name ASC").
$conditions
is always empty or valid SQL ("id < 3" or "id > 10 AND name ILIKE '%megatron%'").
But if $conditions
is empty the query is SELECT [Parts].* FROM [Parts] WHERE AND [robots_id] = ?0 ORDER BY id DESC
and fails.
Passing in an empty ["data"]["conditions"] key shouldn't break the query. If it's empty it shouldn't affect the WHERE clause.