Codeigniter:$query->free_result() when using active record?


Question

after i have finished with my result set from a active record query in a CodeIgniter model, should I use $query->free_result() or does ActiveRecord automatically do that?

1
11
4/17/2018 5:27:02 PM

Accepted Answer

PHP will clean up everything after your script is done. However, if you have lots of queries in, say, a loop, the results will not be cleaned up after each iteration.

So, if you run lots of queries in a loop, you probably will want to free_result() to clear up memory. Otherwise, it's not necessary. See here for details:

https://www.codeigniter.com/user_guide/database/results.html

19
11/10/2018 5:31:50 PM

Licensed under: CC-BY-SA with attribution
Not affiliated with: Stack Overflow
Icon