Yii2 select2 database exception number of bound variables does not match number of tokens

  activerecord, jquery-select2, php, yii2

when i use select2 widget in my yii 2 applicaton, it will cause the following error:

SQLSTATE [HY093]: Invalid parameter number: number of bound variables does not match number of tokens
The SQL being executed was: SELECT * FROM `page` WHERE `page`.`id`=6

The executed sql does not apply my override in find function of Page model as follow:

public static function find()
{
    return parent::find()->where(['websiteId' => Yii::$app->website->id]);
}

Debug stack hint me to beforeInsert() function in ActiveRecord at line 333 & this code:

$this->node->refresh();

Every thing seems ok, so whats wrong?

Source: Ask PHP

LEAVE A COMMENT