CodeIgniter Forums
result() vs. result_array() ? - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: Using CodeIgniter (https://forum.codeigniter.com/forumdisplay.php?fid=5)
+--- Forum: Best Practices (https://forum.codeigniter.com/forumdisplay.php?fid=12)
+--- Thread: result() vs. result_array() ? (/showthread.php?tid=1416)

Pages: 1 2


RE: result() vs. result_array() ? - swand - 04-14-2015

Well, first and foremost , it's your personal choice if you are building app yourself.

Here is a scenario!

Let's suppose you are using some API which requires data in array or object? You will find these functions very useful.


RE: result() vs. result_array() ? - rejoan - 04-21-2015

Use result_array() for better performance. Array is faster than object. I benchmarked two method and got result() execution time is bigger than result_array()


RE: result() vs. result_array() ? - Narf - 04-21-2015

(04-21-2015, 12:45 AM)rejoan Wrote: Use result_array() for better performance. Array is faster than object. I benchmarked two method and got result() execution time is bigger than result_array()

It may be faster in one case, but then it is also slower in others ... That depends on the driver, result size and PHP version being used.

As I said, there's no practical difference.


RE: result() vs. result_array() ? - samiul1978 - 12-15-2019

i read all comments and none give the exact difference between them.
result()  it hold object and cant process more data lets say 37k data but result_array() easily it can. the merrory allocation depend on the server configuration. So remember it.


RE: result() vs. result_array() ? - InsiteFX - 12-16-2019

result() returns an object $this->title

result_array() returns an associated array data['title']


SEE:

CodeIgniter User Guide - Generating Query Results