CodeIgniter Forums
Database Class Hack - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: Archived Discussions (https://forum.codeigniter.com/forumdisplay.php?fid=20)
+--- Forum: Archived Development & Programming (https://forum.codeigniter.com/forumdisplay.php?fid=23)
+--- Thread: Database Class Hack (/showthread.php?tid=30804)



Database Class Hack - El Forum - 05-26-2010

[eluser]Gewa[/eluser]
Hi there. I am building up a multisite application,


and I need following


I need a small hack to the database class so that


On any Update, Delete Query will be added WHERE site_id=$this->config->line('site_id')

On every insert query will be added a column site_id=$this->config->line('site_id') somehow. So that I don't need to edit all the code.
Any ideas where and how I can do this?


Database Class Hack - El Forum - 05-26-2010

[eluser]WanWizard[/eluser]
You can download and install our version of DB.php, and place it in ./system/database.
This will allow you to extend the CI Active Record library.

Then extend the active record library the way you normally extend libraries, and modify the _compile_select(), insert(), update() and delete() methods.

I find this a dangerous thing to do BTW, and I wouldn't recommend you going this route. It can't be to difficult to modify queries in your models, even a large application doesn't have that many...


Database Class Hack - El Forum - 05-26-2010

[eluser]Gewa[/eluser]
You think better to edit application?