activerecord - CodeIgniter: Returning data as an object vs array -


there functions return data either object:

$query = $this->db->query("your query");  if ($query->num_rows() > 0) {    foreach ($query->result() $row)    {       echo $row->title;       echo $row->name;       echo $row->body;    } } 

or array:

$query = $this->db->query("your query");  foreach ($query->result_array() $row) {    echo $row['title'];    echo $row['name'];    echo $row['body']; } 

i've returned data arrays, when case returning "object" preferable?

performance. array better object.

http://www.spearheadsoftwares.com/tutorials/php-performance-benchmarking/50-mysql-fetch-assoc-vs-mysql-fetch-array-vs-mysql-fetch-object


Comments

Popular posts from this blog

ios - RestKit 0.20 — CoreData: error: Failed to call designated initializer on NSManagedObject class (again) -

java - Digest auth with Spring Security using javaconfig -

laravel - PDOException in Connector.php line 55: SQLSTATE[HY000] [1045] Access denied for user 'root'@'localhost' (using password: YES) -