I have 3 tables:
Topics, Users and Details
(those are some of the tables of a custom forum)
Topics contains (among other usual fields) the id (FK) of the user that created the topic. Users contains nick/pass and id (PK) Details contains (among other usual fields) the id (FK) of the user.
Relations: One user can have one 1 detail. One user can have multiple topics, but a topic can be created only by one user.
return array( 'user' => array(self::BELONGS_TO, 'User', 'User_iduser'), );
return array( 'details' => array(self::HAS_ONE, 'Details', 'User_iduser'), );
I’m trying to get a list with Topics and User details (let’s say for example the topic name and the user’s name).
Currently I have this:
$dataProvider=new CActiveDataProvider('Topic', array( 'criteria'=>array( 'with'=>array('user.details') ) ));
But as you can imagine, it’s not working (read as in it’s not selecting anything from the tbles Users or Details).
What’s wrong with my code?
This code selects fields from the table user (and the topic table):
But this one won’t select from details, users and topic:
Also, I need a
solution as I need it for zii widgets (means, even if some kind of modification on the
code get’s to select from the 3 tables it won’t be really helpful)