2014-07-03 67 views
1
$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) 

任何人都可以解釋爲什麼嗎?

回答

5

嘗試

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

能否請您給一個理由,爲什麼這個工程,而不是一有問題.. –

相關問題