title: Array structure returned by Yii's model
body: <p>I am a Yii beginner and am running into a bit of a wall and hope someone will be able to help me get back onto track. I think this might be a fairly straight forward question to the seasoned Yii user. So here goes...</p>
  
  <p>In the controller, let's say I run the following call to the model-</p>
  
  <pre><code>$variable = Post::model()-&gt;findAll();
  </code></pre>
  
  <p>All works fine and I pass the variable into the view. Here's where I get pretty stuck. The array that is returned in the above query is far more complex than I anticipated and I'm struggling to make sense of it. Here's a sample-</p>
  
  <pre><code>print_r($variable);
  </code></pre>
  
  <p>gives-</p>
  
  <pre><code>Array ( [0] =&gt; Post Object ( [_md:CActiveRecord:private] =&gt; CActiveRecordMetaData Object                             ( [tableSchema] =&gt; CMysqlTableSchema Object ( [schemaName] =&gt; [name] =&gt; tbl_post [rawName] =&gt; `tbl_post` [primaryKey] =&gt; id [sequenceName] =&gt; [foreignKeys] =&gt; Array ( ) [columns] =&gt; Array ( [id] =&gt; CMysqlColumnSchema Object ( [name] =&gt; id [rawName] =&gt; `id` [allowNull] =&gt; [dbType] =&gt; int(11) [type] =&gt; integer [defaultValue] =&gt; [size] =&gt; 11 [precision] =&gt; 11 [scale] =&gt; [isPrimaryKey] =&gt; 1 [isForeignKey] =&gt; [autoIncrement] =&gt; 1 [_e:CComponent:private] =&gt; [_m:CComponent:private] =&gt; ) [post] =&gt; CMysqlColumnSchema Object ( [name] =&gt; post [rawName] =&gt; `post` [allowNull] =&gt; [dbType] =&gt; text [type] =&gt; string [defaultValue] =&gt; [size] =&gt; [precision] =&gt; [scale] =&gt; [isPrimaryKey] =&gt; [isForeignKey] =&gt; [autoIncrement] =&gt; [_e:CComponent:private] =&gt; [_m:CComponent:private] =&gt; ) ) [_e:CComponent:private] =&gt; [_m:CComponent:private] =&gt; ) [columns] =&gt; Array ( [id] =&gt; CMysqlColumnSchema Object ( [name] =&gt; id [rawName] =&gt; `id` [allowNull] =&gt; [dbType] =&gt; int(11) [type] =&gt; integer [defaultValue] =&gt; [size] =&gt; 11 [precision] =&gt; 11 [scale] =&gt; [isPrimaryKey] =&gt; 1 [isForeignKey] =&gt; [autoIncrement] =&gt; 1 [_e:CComponent:private] =&gt; [_m:CComponent:private] =&gt; ) [post] =&gt; CMysqlColumnSchema Object ( [name] =&gt; post [rawName] =&gt; `post` [allowNull] =&gt; [dbType] =&gt; text [type] =&gt; string [defaultValue] =&gt; [size] =&gt; [precision] =&gt; [scale] =&gt; [isPrimaryKey] =&gt; [isForeignKey] =&gt; [autoIncrement] =&gt; [_e:CComponent:private] =&gt; [_m:CComponent:private] =&gt; ) ) [relations] =&gt; Array ( [responses] =&gt; CHasManyRelation Object ( [limit] =&gt; -1 [offset] =&gt; -1 [index] =&gt; [through] =&gt; [joinType] =&gt; LEFT OUTER JOIN [on] =&gt; [alias] =&gt; [with] =&gt; Array ( ) [together] =&gt; [scopes] =&gt; [name] =&gt; responses [className] =&gt; Response [foreignKey] =&gt; post_id [select] =&gt; * [condition] =&gt; [params] =&gt; Array ( ) [group] =&gt; [join] =&gt; [having] =&gt; [order] =&gt; [_e:CComponent:private] =&gt; [_m:CComponent:private] =&gt; ) ) [attributeDefaults] =&gt; Array ( ) [_model:CActiveRecordMetaData:private] =&gt; Post Object ( [_md:CActiveRecord:private] =&gt; CActiveRecordMetaData Object *RECURSION* [_new:CActiveRecord:private] =&gt; [_attributes:CActiveRecord:private] =&gt; Array ( ) [_related:CActiveRecord:private] =&gt; Array ( ) [_c:CActiveRecord:private] =&gt; [_pk:CActiveRecord:private] =&gt; [_alias:CActiveRecord:private] =&gt; t [_errors:CModel:private] =&gt; Array ( ) [_validators:CModel:private] =&gt; [_scenario:CModel:private] =&gt; [_e:CComponent:private] =&gt; [_m:CComponent:private] =&gt; ) ) [_new:CActiveRecord:private] =&gt; [_attributes:CActiveRecord:private] =&gt; Array ( [id] =&gt; 1 [post] =&gt; User Post ) [_related:CActiveRecord:private] =&gt; Array ( ) [_c:CActiveRecord:private] =&gt; [_pk:CActiveRecord:private] =&gt; 1 [_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>[sorry if there's an easier way to show this array, I'm not aware of it]</p>
  
  <p>Can anyone explain to me why the model returns such a complex array? It doesn't seem to matter what tables or columns or relations are used in your application, they all seem to me to return this format.</p>
  
  <p>Also, can someone explain the structure to me so that I can isolate the variables that I want to recover?</p>
  
  <p>Many thanks in advance,</p>
  
  <p>Nick</p>