Hello everybody,
I apologize for my English but I’m French and I have not mastered much English !
I would create a database :
-
Table "animes"(cartoons in english) can have several type (for exemple : Action - adventure) who are in the table "animes_genres"
-
Table "animes_genres" can have serveral cartoons (who are in the table "animes")
When I use yiic for generate a model :
and here is the source php generate :
<?php
class animes_has_animes_genres extends CActiveRecord
{
/**
* The followings are the available columns in table 'animes_has_animes_genres':
* @var integer $animes_id
* @var integer $animes_genres_id
*/
/**
* Returns the static model of the specified AR class.
* @return animes_has_animes_genres the static model class
*/
public static function model($className=__CLASS__)
{
return parent::model($className);
}
/**
* @return string the associated database table name
*/
public function tableName()
{
return 'animes_has_animes_genres';
}
/**
* @return array validation rules for model attributes.
*/
public function rules()
{
// NOTE: you should only define rules for those attributes that
// will receive user inputs.
return array(
array('animes_id, animes_genres_id', 'required'),
array('animes_id, animes_genres_id', 'numerical', 'integerOnly'=>true),
// The following rule is used by search().
// Please remove those attributes that should not be searched.
array('animes_id, animes_genres_id', 'safe', 'on'=>'search'),
);
}
/**
* @return array relational rules.
*/
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(
);
}
/**
* @return array customized attribute labels (name=>label)
*/
public function attributeLabels()
{
return array(
'animes_id' => 'Animes',
'animes_genres_id' => 'Animes Genres',
);
}
/**
* 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('animes_id',$this->animes_id);
$criteria->compare('animes_genres_id',$this->animes_genres_id);
return new CActiveDataProvider('animes_has_animes_genres', array(
'criteria'=>$criteria,
));
}
}
?>
Relation is empty !!!!
When a I use yiic for generate CRUD :
What can I do to solve this problem ?