PHP中的数据标准?

This might be a stupid question but i havent been able to find any kind of answers. So im turning to the place where i can always fin an answer. I am using CodeIgniter framework. I was wondering if there is a standard for classes to return data?

Sometimes im returning data as an array (whether it be multi or single dimensional) Other times i am returning data as an object.

$query = $this->db-query($sql);
$result = $query->result(); // returned as object    
foreach( $result as $row)
{
  $row->title
  $row->body
}

OR

$result = $query->result_array(); //multidimensional array
foreach($result as $row)
{
  $row['title']
  $row['body']
} 

Which is better for templating? Or what are the pros and cons of each?

You can use objects as simple container values (although it would probably be easier to use arrays for this). In my opinion, it is mostly up to your personal taste whether to use arrays or standard objects. The only important point, concerning clean code, is to use arrays or objects consistently (to avoid unnecessary confusion).

Objects are really not meant as simple containers with public properties while arrays are. Therefore you should go with arrays.

Doesn't really change that much for styling purposes.

When your object is not a real object but just a disguised array - better make it explicit array.