0

我有一个名为 Activity 的模型,其中 search() 定义如下。但我想不出为什么当我这样称呼它时会提示这个错误..

未定义内部服务器错误属性“CActiveDataProvider.select”。

调用方式..

//获取数据 $model = new $modelName(); if ($modelName === "活动") $criteria = $model->search(); 否则 $criteria = unserialize(base64_decode($criteria));

$rows = $model->commandBuilder->createFindCommand($model->tableSchema, $criteria)->queryAll();

我在这里做错了什么?谁能帮我解决这个问题

   public function search() {
      $criteria = new CDbCriteria();
      $criteria->select = 't.id,t.activity_id,t.type,t.sub_type,t.name,t.description,t.source,t.delete_req,t.delete_reason,s.id as session_id, s.site_id, 
      s.location, s.start_time, s.end_time, j.id as Participants as s.closed, c.first_name, j.attended, c.managed_by_id';
      $criteria->join = 'left join activity_sessions s on t.id = s.activities_id 
         left join activity_jobseekers j on s.id = j.session_id
         left join contacts c on j.contact_id = c.id';
      // Case insensitive compare
      if (!empty($this->activity_id))
         $criteria->addSearchCondition("t.activity_id", $this->activity_id.'%', false, 'AND', 'ILIKE');
      if (!empty($this->type))
         $criteria->addSearchCondition("t.type", $this->type.'%', false, 'AND', 'ILIKE');
      if (!empty($this->sub_type))
         $criteria->addSearchCondition("t.sub_type", $this->sub_type.'%', false, 'AND', 'ILIKE');
      if (!empty($this->name))
         $criteria->addSearchCondition("t.name", $this->name.'%', false, 'AND', 'ILIKE');
      if (!empty($this->description))
         $criteria->addSearchCondition("t.description", $this->description.'%', false, 'AND', 'ILIKE');
      if ($this->source !== null)
         $criteria->compare('t.source', $this->source, false);

      $criteria->addCondition("t.delete_req='0'");

      return new CActiveDataProvider('Activity', array(
         'criteria'=>$criteria,
         'sort'=>array('defaultOrder'=>'t.id ASC'),
         'pagination'=>array('pageSize'=>Yii::app()->params['DefaultPageSize']),
      ));
   }
4

1 回答 1

2

U 应该返回CDbCriteria对象,而不是在搜索方法中返回CActiveDataProvider提供程序对象。

希望这可以帮助..

于 2013-09-18T05:11:18.493 回答