bindValues is not accepting one value in (where in array) in ActiveQuery

Hello,
This is my code

$query = "SELECT * FROM users WHERE id IN (:id_array)";
return Yii::$app->db->createCommand($query)->bindValues([
         ':id_array' => [6]
      ])->queryAll();

This code above not working, this error appears “Undefined array key 1”, when the array length is one.
While the following code works fine :

$query = "SELECT * FROM users WHERE id IN (:id_array)";
return Yii::$app->db->createCommand($query)->bindValues([
         ':id_array' => [6,5]
      ])->queryAll();

The difference between the 2 codes is the array length.
And for another reasons I have to use ActiveQuery not ActiveRecord

PDO itself does not support binding arrays, and I can see in the code that here it was done like that to still allow providing an array although with only one element (the rest is ignored and apparently it causes errors, it’s declared as deprecated anyway). Please use QueryBuilder for your case where these array params are handled properly.

:+1: :+1:
Clear, Thank you.