This query work correctly when user that user.rank is 1 is not included in $userIds
.but, this query not work when user that user.rank is 1 is included in $userIds
.
so what's happen!?.
phalcon's version is 3.1.
$userIds = [1,2,3,4];
$increasedCount = 1;
var_dump($increasedCount);
switch ($increasedCount) {
case $increasedCount > 0:
$countSql = "+ " . $increasedCount;
break;
case $increasedCount < 0:
$countSql = "- " . abs($increasedCount);
break;
default:
return false;
}
$user = new UserEntity();
try {
$phql = "UPDATE Application\Models\Entities\User SET rank = rank $countSql WHERE id IN (" . implode(",", $userIds) . ")";
return $user->getModelsManager()->executeQuery($phql);
} catch (Exception $e) {
return false;
}