3 useful method extend CI DB |
[eluser]vps4[/eluser]
feature & usage: get_var() get_row() get_col() these method like wordpress DB. Code: $id = $this->db->get_var('SELECT COUNT(id) FROM table'); just open /* Location: ./system/database/DB_driver.php */ add this codes: Code: // -------------------------------------------------------------------- enjoy!
[eluser]sophistry[/eluser]
seems useful to have these "macro" functions. however, rather than putting them in the db class i would put these in your own base Model class and extend all models from there. cheers. EDIT: changed for clarity on base model name
[eluser]Dan Horrigan[/eluser]
You should NEVER add code into the base classes. You should, instead, EXTEND them. The User Guide says you cannot extend the database classes. However, there is a way. Here is the article explaning how to do it: http://codeigniter.com/wiki/Extending_Database_Drivers/ If you edited your base files as you have above, then anytime you upgrade CI, you will have to go in and re-implement them. Also, extending the classes makes it much easier to use them on other projects. |
Welcome Guest, Not a member yet? Register Sign In |