我想搜索一些模型事件,同时按时间和相关用户过滤它们。我在网格中做它工作正常。然而,当我在网格输入中额外输入一些数据以搜索事件的其他属性时,ajax 响应会出现:无效的参数编号:绑定变量的数量与标记的数量不匹配。 'IN 条件'(显示在查询中)被添加到条件中:
$newCriteria = new CDbCriteria;
// get events id (several ) of current user
$events = $model->getEvents($currentUser);
// add the condition into criteria; 't' being the model table alias
if ($events) $newCriteria->addInCondition('t.Id', $events);
// merge with criteria from the model (DocEvents)
$newCriteria->mergeWith($model->criteria());
$dataProvider = new CActiveDataProvider('DocEvents', array(
'criteria'=>$newCriteria,//$model->criteria(),
));
$this->widget('bootstrap.widgets.TbGridView', array(
'dataProvider'=>$dataProvider,
'filter'=>$model,'columns'=>array(
'Id',
'Subject',
'EventTypeId',
'Begin',
'End',
array(
'class'=>'bootstrap.widgets.TbButtonColumn',
),
),
));
模型文件中的标准:
public function criteria()
{
$criteria=new CDbCriteria;
$criteria->compare('Id',$this->Id);
$criteria->compare('Subject',$this->Subject,true);
$criteria->compare('Notes',$this->Notes,true);
$criteria->compare('Place',$this->Place,true);
$criteria->compare('EventTypeId',$this->EventTypeId,true);
$criteria->compare('Percentage',$this->Percentage);
$criteria->compare('ReflectInCalendar',$this->ReflectInCalendar);
$criteria->compare('ParentId',$this->ParentId);
$criteria->compare('Priority',$this->Priority);
$criteria->compare('StatusId',$this->StatusId);
$criteria->compare('Comment',$this->Comment,true);
$criteria->compare('PlanHours',$this->PlanHours);
$criteria->compare('Tags',$this->Tags,true);
$conditions=array();
if ($this->Begin) $conditions[] = 'Begin >= "' . $this->Begin . '" ';
if ($this->End) $conditions[] = 'End <= "' . $this->End . '" ';
$criteria->condition = implode(' AND ', $conditions);
return $criteria;
}
如何解决问题?