My League class
/**
* This is the model class for table "league".
*
* The followings are the available columns in table 'league':
* @property integer $id
* @property string $name
* @property integer $size
* @property integer $exchange_down
* @property integer $id_season
*/
class League extends CActiveRecord
{
public $id_season = 0;
...
public function relations()
{
return array(
'players' => array(self::HAS_MANY, 'PlayerStat', 'id_league',
'condition'=>'id_season = ' . $this->id_season),
);
}
My Season class
public function getLeagues()
{
if(!$this->_leagues)
foreach(League::model()->findAll() AS $League)
{
//the ID I assign here is always ignored by League which always uses the default ID of 0
//what can I do about this?
$League->id_season = $this->id;
$this->_leagues[] = $League;
}
return $this->_leagues;
}
How do I get League/CActiveRecord to use the $id_season I assign it, rather than the default: 0? I’m guessing the problem caused by static methods.