Hello!
The first code results in 1 row being returned, while the second one returns the expected 2 rows. Why does Phalcon return 2 different results?
This script is supposed to return all the rows that have user_id
equal to 11 or 13.
Yet it returns only 1 row when binding is involved.
The difference between the 2 codes is that in the second code snippet I directly input the $user_ids
variable in the where
.
FIRST:
$user_ids = "11, 13";
$this->modelsManager->registerNamespaceAlias('OT', 'App\Models');
$userSuspensions = $this->modelsManager->createBuilder()
->from("OT:UsersSuspensions")
->columns('user_id, ended')
->where("user_id IN (:user_ids:)", ["user_ids" => $user_ids])
->getQuery()
->execute();
SECOND:
$user_ids = "11, 13";
$this->modelsManager->registerNamespaceAlias('OT', 'App\Models');
$userSuspensions = $this->modelsManager->createBuilder()
->from("OT:UsersSuspensions")
->columns('user_id, ended')
->where("user_id IN ($user_ids)", ["user_ids" => $user_ids])
->getQuery()
->execute();