[right]
سلام
دوتا جدول دارم جدول گروه و جدول عکس
و برای نمایش عکس ها از گرید استفاده میکنم
توی تابع سرچ کدهای زیرو نوشتم ولی خطا میده فک کنم خطاش مربوط به کلید خارجی میشه
ولی بین دوتا جدول ارتباط بر قراره وقتی کد زیرو بهش اضافه میکنم بهم خطا میده
[/right]
CDbCommand failed to execute the SQL statement: SQLSTATE[23000]: Integrity constraint violation: 1052 Column 'id' in order clause is ambiguous. The SQL statement executed was: SELECT `t`.`id` AS `t0_c0`, `t`.`id_user` AS `t0_c1`, `t`.`data` AS `t0_c2`, `t`.`name` AS `t0_c3`, `t`.`flag` AS `t0_c4`, `t`.`id_group` AS `t0_c5`, `idGroup`.`id` AS `t1_c0`, `idGroup`.`id_user` AS `t1_c1`, `idGroup`.`name` AS `t1_c2` FROM `news_file_upload` `t` LEFT OUTER JOIN `news_group` `idGroup` ON (`t`.`id_group`=`idGroup`.`id`) ORDER BY id DESC LIMIT 5
$criteria->with = array('idGroup');
$criteria->addSearchCondition('idGroup.name', $this->title_group);
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(
'idUser' => array(self::BELONGS_TO, 'User', 'id_user'),
'idGroup' => array(self::BELONGS_TO, 'Group', 'id_group'),
);
}
/**
* @return array customized attribute labels (name=>label)
*/
public function attributeLabels()
{
return array(
'id' => 'ID',
'id_user' => 'Id User',
'data' => 'Data',
'name' => 'Name',
'flag' => 'Flag',
'id_group' => 'Id Group',
);
}
/**
* Retrieves a list of models based on the current search/filter conditions.
*
* Typical usecase:
* - Initialize the model fields with values from filter form.
* - Execute this method to get CActiveDataProvider instance which will filter
* models according to data in model fields.
* - Pass data provider to CGridView, CListView or any similar widget.
*
* @return CActiveDataProvider the data provider that can return the models
* based on the search/filter conditions.
*/
public function search()
{
// @todo Please modify the following code to remove attributes that should not be searched.
$criteria=new CDbCriteria;
$criteria->compare('id',$this->id);
$criteria->compare('id_user',$this->id_user);
$criteria->compare('data',$this->data,true);
$criteria->compare('name',$this->name,true);
$criteria->with = array('idGroup');
$criteria->addSearchCondition('idGroup.name', $this->title_group);
return new CActiveDataProvider($this, array(
'criteria'=>$criteria,'pagination'=>array( 'pageSize'=>5,),
'sort'=>array( 'defaultOrder'=>'id DESC ',),
));
}