title: yii CActiveDataProvider Multiple Table Join
body: <p>I'm working on a magazine site right now and I'm having trouble with getting Yii to return all data with CActiveDataProvider. The SQL query runs fine when run through SQL, and I receive no errors in Yii when it's run. Checking logs, the whole SQL statement is being run when put through Yii. </p>
  
  <pre><code>public function actionIndex()
  {
      $this-&gt;layout = '//layouts/column1';
  
      if(isset($_GET['cat']))
      {
          $cat = $_GET['cat'];
          $catname = Yii::app()-&gt;db-&gt;createCommand();
          $catname-&gt;select='category_name';
          $catname-&gt;from='category';
          $catname-&gt;where('id=:cid', array(':cid'=&gt;$cat));
          $categoryname = $catname-&gt;queryScalar();
  
          $criteria = new CDbCriteria();
          $criteria-&gt;alias = 'article';
          $criteria-&gt;select ='article.id, article.title, article.content, article.date_published, image.file_name, image.alt_text, author.first_name, author.last_name';
          $criteria-&gt;join='INNER JOIN category_article ON article.id = category_article.article_id ';
          $criteria-&gt;join.='INNER JOIN image ON image.article_id = article.id ';
          $criteria-&gt;join.='INNER JOIN author ON author.id = article.author_id';
          $criteria-&gt;condition='category_article.category_id=:cid AND article.completed = 3 AND article.live = 1 AND article.review = 1';
          $criteria-&gt;params=array(':cid'=&gt;$cat);
          $dataProvider=new CActiveDataProvider('Article', array('criteria'=&gt;$criteria));
  
          $this-&gt;render('index',array(
              'dataProvider'=&gt;$dataProvider,
              'cat'=&gt;$cat,
              'categoryname'=&gt;$categoryname,
          ));
          Yii::app()-&gt;end();
      }
  
      $dataProvider=new CActiveDataProvider('Category');
      $this-&gt;render('index',array(
          'dataProvider'=&gt;$dataProvider,
      ));
  }
  </code></pre>
  
  <p>In case it's needed, here are the relations for the article model:</p>
  
  <pre><code>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(
          'author' =&gt; array(self::BELONGS_TO, 'Author', 'author_id'),
          'articleCounts' =&gt; array(self::HAS_MANY, 'ArticleCount', 'article_id'),
          'articleNote' =&gt; array(self::HAS_ONE, 'ArticleNote', 'article_id'),
          'categories' =&gt; array(self::MANY_MANY, 'Category', 'category_article(article_id, category_id)'),
          'comments' =&gt; array(self::HAS_MANY, 'Comment', 'article_id'),
          'featureds' =&gt; array(self::HAS_MANY, 'Featured', 'article_id'),
          'image' =&gt; array(self::HAS_ONE, 'Image', 'article_id'),
          'nonmembercomments' =&gt; array(self::HAS_MANY, 'Nonmembercomment', 'article_id'),
          'tags' =&gt; array(self::MANY_MANY, 'Tag', 'postid_tagid(article_id, tag_id)'),
          'videos' =&gt; array(self::HAS_ONE, 'Video', 'article_id'),
      );
  }
  </code></pre>
  
  <p>and here is the print_r printout:</p>
  
  <pre><code>Article Object
  (
      [_new:CActiveRecord:private] =&gt; 
      [_attributes:CActiveRecord:private] =&gt; Array
          (
              [id] =&gt; 56
              [title] =&gt; Hello My Lovely
              [content] =&gt; Lorem ipsum dolor sit amet, consectetur adipiscing elit. Morbi a arcu dictum, tincidunt libero vel, imperdiet ante. Proin consectetur risus vel purus vestibulum, nec scelerisque felis posuere. Maecenas ut erat lobortis, rhoncus tellus at, ultricies turpis. Donec pretium aliquet mi. Integer luctus interdum magna, quis dictum ligula bibendum sed. Curabitur nibh felis, sollicitudin hendrerit nunc eget, interdum fringilla leo. Cras consectetur elit metus, at tempus erat vehicula quis.
  
  
  
          [date_published] =&gt; 2014-07-15 23:16:07
      )
  
  [_related:CActiveRecord:private] =&gt; Array
      (
          [image] =&gt; Image Object
              (
                  [_new:CActiveRecord:private] =&gt; 
                  [_attributes:CActiveRecord:private] =&gt; Array
                      (
                          [id] =&gt; 36
                          [article_id] =&gt; 56
                          [file_name] =&gt; hello-you20140624190852.jpg
                          [image_name] =&gt; Hello You
                          [alt_text] =&gt; My Hottie!
                      )
  
                  [_related:CActiveRecord:private] =&gt; Array
                      (
                      )
  
                  [_c:CActiveRecord:private] =&gt; 
                  [_pk:CActiveRecord:private] =&gt; 36
                  [_alias:CActiveRecord:private] =&gt; t
                  [_errors:CModel:private] =&gt; Array
                      (
                      )
  
                  [_validators:CModel:private] =&gt; 
                  [_scenario:CModel:private] =&gt; update
                  [_e:CComponent:private] =&gt; 
                  [_m:CComponent:private] =&gt; 
              )
  
          [author] =&gt; 
      )
  
  [_c:CActiveRecord:private] =&gt; 
  [_pk:CActiveRecord:private] =&gt; 56
  [_alias:CActiveRecord:private] =&gt; t
  [_errors:CModel:private] =&gt; Array
      (
      )
  
  [_validators:CModel:private] =&gt; 
  [_scenario:CModel:private] =&gt; update
  [_e:CComponent:private] =&gt; 
  [_m:CComponent:private] =&gt; 
  )
  </code></pre>
  
  <p>As you can see, everything from the query is returned and yet the author remains blank and I'm not sure why. I did notice the image object did the same thing until I changed the relation in the article model to HAS_ONE, which is fine since each article will only have one image associated with it. Anyone see anything wrong in the way it's written that would be causing that issue? Thanks to all answers in advance.</p>