Update Command says: Invalid parameter number: :time

Hi.

I have the following error:




SQLSTATE[HY093]: Invalid parameter number: :time

Failed to prepare SQL: UPDATE "user" SET "online_at"=:qp2 WHERE "id"=:qp3



But this is not true, because I have added the :time parameter too:


return $this->createCommand()

            ->update(User::tableName(), ['online_at' => ':time'], ['id' => ':id'], [':time' => time(), ':id' => \Yii::$app->user->getId()])

            ->execute();

I want to update the online_at value, but via update command. I do not want to use the Active Record’s save method, because it is not enough lightweight than the simple update command.

Probably …




return $this->createCommand()

            ->update(User::tableName(), ['online_at' => ':time'], ['id' => \Yii::$app->user->getId()], [':time' => time()])

            ->execute();


// or

return $this->createCommand()

            ->update(User::tableName(), ['online_at' => time()], ['id' => \Yii::$app->user->getId()])

            ->execute();