I use both
Usually i like to get my result as array thats why i use result_array() mostly..
But i want to know which is the better approach that i should follow, Which one of them is more efficient to use in regards to performance?
Here is the Example i am talking about in codeigniter queries
$query = $this->db->get(); $result = $query->result_array();
or is this should be the better approach??
$query = $this->db->get(); $result = $query->result();
also right now i am using result_array in my generic model.
Result has an optional
$typeparameter which decides what type of result is returned. By default (
$type = "object"), it returns an object (
result_object()). It can be set to
"array", then it will return an array of result, that being equivalent of caling
result_array(). The third version accepts a custom class to use as a result object.
The code from CodeIgniter:
Arrays are technically faster, but they are not objects. It depends where do you want to use the result. Most of the time, arrays are sufficient.