Search code examples
mysqlyiidataprovider

Invalid Parameter Number:number of bound variables does not match number of tokens


 $dataProvider=$model->search();

 $dataProvider->criteria->addcondition('company_code= :id')->params=array(':id' => $company);

 $this->widget('zii.widgets.grid.CGridView', array(
'id'=>'tblapptcodegrid',
'dataProvider'=>$dataProvider,
'filter'=>$model,

The data is displayed correctly, but when i try to search in filter; it comes with the error

CDbCommand failed to execute the SQL statement: SQLSTATE[HY093]: Invalid parameter number: number of bound variables does not match number of tokens. The SQL statement executed was: SELECT COUNT(*) FROM `tblapptcode` `t` WHERE (appt_code LIKE :ycp0) AND (company_code= :id) (C:\wamp\www\yii\framework\db\CDbCommand.php:543)

Can anyone explain why?


Solution

  • try

    $dataProvider->criteria->addcondition('company_code= :id')->params[':id'] = $company;