I have 3 tables. car_types: id | main_image | title car_type_classifiers: id | car_type_id | classifier_id classifiers: id | class
I want to display a CGridView so there are columns: Title | class. But Classes can be many for one car_type. I tried to search online, but coudnt understand those $criteria->compare() functions in model search function.
I want those to show up as little lists. How can I do that? my view:
public function actionIndex()
{
$model=new EeCarTypes('search');
$model->unsetAttributes();
$this->render('index',array('model'=>$model));
}
and my model:
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('car_type',$this->car_type,true);
return new CActiveDataProvider($this, array(
'criteria'=>$criteria,
));
}
can you post an example of what your tying to do? Maybe a picture? i.e. are you trying to show the car name with a picture and car models?
How is the info stored? Is all the info in different tables? if so post the relations if you have them. Just a little bit more info will go a long way here.
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('car_type',$this->car_type,true);
$criteria->compare('classifiers',$this->classifiers, true);
$criteria->compare('main_image',$this->main_image);
$criteria->compare('assigned_images',$this->assigned_images);
return new CActiveDataProvider($this, array(
'criteria'=>$criteria,
));
}