title: Selecting from multiple tables with Yii's CActiveDataProvider
body: <p>I have 3 tables: <code>Topics</code>, <code>Users</code> and <code>Details</code> (those are some of the tables of a custom forum)</p>
  
  <p><code>Topics</code> contains (among other usual fields) the id (FK) of the user that created the topic.
  <code>Users</code> contains nick/pass and id (PK)
  <code>Details</code> contains (among other usual fields) the id (FK) of the user.</p>
  
  <p>Relations:
  One user can have one 1 detail.
  One user can have multiple topics, but a topic can be created only by one user.</p>
  
  <p>Topic relations:</p>
  
  <pre><code>return array(
  'user' =&gt; array(self::BELONGS_TO, 'User', 'User_iduser'),
  );
  </code></pre>
  
  <p>User relations:</p>
  
  <pre><code>return array(
      'details' =&gt; array(self::HAS_ONE, 'Details', 'User_iduser'),
  );
  </code></pre>
  
  <p>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).</p>
  
  <p>Currently I have this:</p>
  
  <pre><code>$dataProvider=new CActiveDataProvider('Topic', array(
      'criteria'=&gt;array(
      'with'=&gt;array('user.details')
      )
  ));
  </code></pre>
  
  <p>But as you can imagine, it's not working (read as in it's not selecting anything from the tbles Users or Details).</p>
  
  <p>What's wrong with my code?</p>
  
  <p><br>
  +++++++++++++++
  <br><br></p>
  
  <p>This code selects fields from the table user (and the topic table):</p>
  
  <pre><code>Topic::model()-&gt;with('user')-&gt;findAll();
  </code></pre>
  
  <p><br></p>
  
  <p>But this one won't select from details, users and topic:</p>
  
  <pre><code>Topic::model()-&gt;with('user.details')-&gt;findAll();
  </code></pre>
  
  <p>Also, I need a <code>CActiveDataProvider</code> solution as I need it for zii widgets (means, even if some kind of modification on the <code>Topic::model()-&gt;with()....</code> code get's to select from the 3 tables it won't be really helpful)</p>
  
  <p>EDIT: (SQL log from Yii)</p>
  
  <pre><code>Querying SQL: SELECT COUNT(DISTINCT `t`.`idtema`) FROM `tema` `t`  LEFT
  OUTER JOIN `usuario` `usuarioIdusuario` ON
  (`t`.`Usuario_idusuario`=`usuarioIdusuario`.`idusuario`)  LEFT OUTER JOIN
  `detallesusuario` `detallesusuario` ON
  (`detallesusuario`.`Usuario_idusuario`=`usuarioIdusuario`.`idusuario`) 
  
  Querying SQL: SELECT `t`.`idtema` AS `t0_c0`, `t`.`Usuario_idusuario` AS
  `t0_c1`, `t`.`Categoria_idcategoria` AS `t0_c2`, `t`.`tema` AS `t0_c3`,
  `t`.`fecha_hora` AS `t0_c4`, `usuarioIdusuario`.`idusuario` AS `t1_c0`,
  `usuarioIdusuario`.`nick` AS `t1_c1`, `usuarioIdusuario`.`contrasena` AS
  `t1_c2`, `usuarioIdusuario`.`email` AS `t1_c3`,
  `detallesusuario`.`Usuario_idusuario` AS `t2_c0`,
  `detallesusuario`.`nombre` AS `t2_c1`, `detallesusuario`.`apellidos` AS
  `t2_c2`, `detallesusuario`.`cumpleanos` AS `t2_c3`,
  `detallesusuario`.`telefono1` AS `t2_c4`, `detallesusuario`.`telefono2` AS
  `t2_c5` FROM `tema` `t`  LEFT OUTER JOIN `usuario` `usuarioIdusuario` ON
  (`t`.`Usuario_idusuario`=`usuarioIdusuario`.`idusuario`)  LEFT OUTER JOIN
  `detallesusuario` `detallesusuario` ON
  (`detallesusuario`.`Usuario_idusuario`=`usuarioIdusuario`.`idusuario`) 
  LIMIT 10
  </code></pre>