relations and null

My EncomendaLinhas relations:


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(

			'encomenda' => array(self::BELONGS_TO, 'Encomenda', 'encomenda'),

			'ritmo' => array(self::BELONGS_TO, 'Ritmo', 'style'),

		);

	}

My code and $encomendaLinha->ritmo is null,i dont know why

action finalizar


if (isset($_GET['encomenda'])) {

            $encomenda = Encomenda::model()->findByPk($_GET['encomenda']);

            $encomenda->confirmed = true;

            $encomenda->save();

            

            

            foreach ($encomenda->encomendaLinhas as $encomendaLinha) :

                       $lista= $lista.$encomendaLinha->ritmo;


                endforeach;

                

        

May be because it doesn’t have any of ritmo in Db? And for making “$lista= $lista.$encomendaLinha->ritmo;” you need to overwrite ritmo __toString().

i forgot the import:

Yii::import(‘application.modules.admin.models.*’);

thank you