We have moved our forum to GitHub Discussions. For questions about Phalcon v3/v4/v5 you can visit here and for Phalcon v6 here.

Passing in Empty Conditions Breaks Query

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").

$conditionsis 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.

This seems like something that should be posted as a bug report.