Hello!

I've stumbled upon an issue I can't seem to solve with the help of documentation or google. The code I have boils down to this:

$ownerIds = [31, 32];
$sum1 = (int) MyModel::sum([
    'column' => 'clicks',
    'conditions' => "(ownerId IN ({ids:array}))",
    'bind' => [
        'ids' => $ownerIds
    ]
]);

$ownerIds = [31, 32, 33];
$sum2 = (int) MyModel::sum([
    'column' => 'clicks',
    'conditions' => "(ownerId IN ({ids:array}))",
    'bind' => [
        'ids' => $ownerIds
    ]
]);

This results in the following error:

PDOException: SQLSTATE[HY093]: Invalid parameter number: number of bound variables does not match number of tokens

Backtrace shows that Phalcon generated an incorrect query:

Phalcon\Db\Adapter\Pdo->query(SELECT SUM(user_stats.clicks) AS sumatory FROM user_stats WHERE (user_stats.owner_id IN (:ids0, :ids1)), Array([ids] => Array([0] => 31, [1] => 32, [2] => 33)), null)

The IN element contains placeholders for only 2 elements of the array, even though the array has 3 of them. For some reason, the condition generated in the first MyModel::sum request persists into the second request and causes the error.

Is there any workaround that can fix this? In my code the first and the second requests are in 2 different object instances, so I cannot rename "ids" into something else on each request.