Есть 4 таблицы для размеров, s_height, s_width, s_depth и одна общая sizes, которая содержит в себе ID-шники всех трёх. Как мне её вывести через CGridView, чтобы вместо ID были сами значения этих таблиц? Может я не совсем корректно написал топик? Куда почитать?
ps:
все relations между таблицами настроены.
pps:
поля таблиц s_height, s_width, s_depth - id, value
поля таблицы sizes - id, id_height, id_width, id_depth
Да, в search() при создании CDbCriteria. Можно, конечно, и не соединять сразу все таблицы, а просто обращаться к $data->height, но тогда для каждой строки будет выполнен SQL запрос к базе, чтобы подгрузить связанные объекты.
Почти всё получилось, отказали фильтры по умолчанию CDbCriteria. Нужно как-то дополнительно настроить свойство filter в гриде или Compare в search()… но как… можно пример?
Это мой сёрч от size…
/**
* Retrieves a list of models based on the current search/filter conditions.
* @return CActiveDataProvider the data provider that can return the models based on the search/filter conditions.
*/
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);
$criteria->compare('width',$this->width);
$criteria->compare('height',$this->height);
$criteria->compare('depth',$this->depth);
$criteria->with = array('s_width','s_height','s_depth');
return new CActiveDataProvider($this, array(
'criteria'=>$criteria,
));
}
public function search()
{
// Warning: Please modify the following code to remove attributes that
// should not be searched.
$criteria=new CDbCriteria;
$criteria->with = array('s_width','s_height','s_depth');
$criteria->compare('id',$this->id);
$criteria->compare('s_width.value',$this->width);
$criteria->compare('s_height.value',$this->height);
$criteria->compare('s_depth.value',$this->depth);
return new CActiveDataProvider($this, array(
'criteria'=>$criteria,
));
}
Судя по всему, вместо ручного ввода значения вам больше подойдет фильтрация с помощью выпадающих списков для width, height и depth. Для этого нужно в filter каждой колонки указать массив допустимых значений, тогда должен нормально работать и первый вариант метода search().