Custom backport of unbuffered_row in CI2 |
In a CI2 project I work on, I really need the unbuffered_row() function that exists only in CI3. The project will be migrated to CI3 later this year, but for now I want to add the function in CI2 to address a memory issue. Here are the changes I made. Can someone knowing very well how the database classes works, tell me if those changes will cause problems? Especially the removal of the call to num_rows().
This is what I added to system/database/DB_result.php: PHP Code: public function unbuffered_row($type = 'object') In system/database/DB_driver.php, near the end of the query() function, I removed the call to num_rows() because it fetched all the rows. Also, it's not there in CI3, and for now I haven't seen any problem: PHP Code: // oci8 vars must be set before calling this So, will it work? Thank you for your feedback! PS: I know very well it's a bad idea to make changes to core classes, but it's a temporary fix. The project will be migrated to CI3 later this year.
CodeIgniter 4 tutorials (EN/FR) - https://includebeer.com
/*** NO support in private message - Use the forum! ***/
Ok, obviously, the num_rows variable is not set before calling result_array() (this is for my other queries not using unbuffered_row).
So I should change this : PHP Code: if($query->num_rows > 0) To this : PHP Code: if($query->num_rows() > 0) And I think it will work...
CodeIgniter 4 tutorials (EN/FR) - https://includebeer.com
/*** NO support in private message - Use the forum! ***/
One last change, num_rows must be set to 0. Now I think it works.
PHP Code: // oci8 vars must be set before calling this @Narf, @kilishan, I'd like your feedback on this. Am I shooting myself in the foot?
CodeIgniter 4 tutorials (EN/FR) - https://includebeer.com
/*** NO support in private message - Use the forum! ***/ |
Welcome Guest, Not a member yet? Register Sign In |