Data Base Relation

salam khedmate hameye doostan ,

soalma ro ye joor dg matrah konam , baz mamnoon misham rahnemaiim konid

man mikham az tarig modele post be feild image az modle profile beresam baraye inkar bayad chikar konam ?? chetori az relatiion ha estefade konam ?/

in moshkel ba estefade az ‘through’ hal shod be in sorat ke baraye residan az Post be profile dar model Post :


    public  function relations(){

        return array(

            "content"=>array(self::BELONGS_TO,"Content","content_id"),

            "user"=>array(self::BELONGS_TO,"User",array('user_id'=>'id'),"through"=>'content'),

            "profile"=>array(self::HAS_ONE,"Profile",array('id'=>'user_id'),"through"=>'user'),




        );

    }

controller :




$data=$model->with('content','user','profile')->model()->findAll();



va saranjam :




$data->profile->image;



albate emidoonam chera in ravesh javab nadad :

$data->content->user->profile->image;