CI_DB_active_record class extension in codeigniter 2.0

I am writing my first program using Codeigniter and ran into a problem. I will start with a focused description of the problem and can expand it if I need:

I need to write a multidimensional array in the database and you want to use the insert_batch function from the CI_DB_active_record class to do this. The problem is that I need to write empty values ​​as NULL for some fields, while other fields should be empty. The current function wraps all values ​​in single quotes, and I cannot find a way to write null values ​​to the database for the specified fields.

I would also like to increase the number of entries per package.

I see how to extend models, libraries, etc., but is there a way to extend the CI_DB_active_record class without changing the main classes? The minimum modification size of the main class to do this work, which I found, changes the following lines in the DB.php file (changing the require_once file to a new file that extends the CI_DB_active_record class and changes the CI_DB_active_record class name to the new class name):

require_once(BASEPATH.'database/DB_active_rec'.EXT); if ( ! class_exists('CI_DB')) { eval('class CI_DB extends CI_DB_active_record { }'); } 

Can i do better?

+3
source share
3 answers
0
source

There is no ready-made solution for this. Your hacking is a reasonable decision, and if he performs the task, then on it.

If you have any changes in relation to the kernel (there is a lot of room for improvement in some parts of AR), then why not jump on BitBucket and help with Reactor?

https://bitbucket.org/ellislab/codeigniter-reactor

+2
source

As abmc hints, this can be done by modifying the bootloader. It is also necessary to change the database. All this can be done inside the application / kernel folder, so the system files remain untouched. Detailed description here: http://dtownsend.co.uk/blog/2013/01/extending-cis-active-record

+2
source

All Articles