参数号无效:绑定变量数与令牌数不匹配

时间:2014-07-03 08:33:02

标签: mysql yii dataprovider

 $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,

数据显示正确,但是当我尝试搜索过滤器时;它带有错误

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)

任何人都可以解释原因吗?

1 个答案:

答案 0 :(得分:4)

尝试

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