clumsyboy 2011-05-31 09:55:00 3809次浏览 0条回复 0 0 0

我在search()里做了一个字段的联表操作

public function relations()
{
  // NOTE: you may need to adjust the relation name and the related
  // class name for the relations automatically generated below.
  return array(
    'show' => array(self::BELONGS_TO, 'Shows', 'show_id'),
  );
  }
public function search()
{
  // Warning: Please modify the following code to remove attributes that
  // should not be searched.
  $criteria=new CDbCriteria;
  $criteria->compare('id',$this->id,true);
  $criteria->compare('name',$this->name,true);
  $criteria->with = array('show');
  $criteria->condition = 'show.name like "%'.$this->show_id.'%"';
  $criteria->compare('IP',$this->IP,true);
  $criteria->compare('fettles',$this->fettles,true);

然后在view/admin列表页按默认方法进行查询 但是出现一个问题

$criteria->with = array('show');
$criteria->condition = 'show.name like "%'.$this->show_id.'%"';

这段代码之后的字段能正常查询,它前面的2个字段就没法实现查询功能

求解?

    没有找到数据。
您需要登录后才可以回复。登录 | 立即注册