Relation AR

Hello all,

I am creating my back office for managing my CV.

The table is as follow:











So I set up :

In cv_category model:


In cv_text model:


When I am trying to retrieve all category from cv_text controler:

$cv_texte = new cv_texte;

$criteria = new CDbCriteria;




I am stuck with : How can I get the title of the category?

In your relations() method, you should use 'cv_category' instead of 'id_cv_category' as the relation name.

Given a cv_texte AR instance, you can access the category title via $cv_texte->cv_category->title.

Thank you very much Qiang it works! :)