![]() |
Simple database CRUD for Codeigniter - Printable Version +- CodeIgniter Forums (https://forum.codeigniter.com) +-- Forum: Archived Discussions (https://forum.codeigniter.com/forumdisplay.php?fid=20) +--- Forum: Archived Libraries & Helpers (https://forum.codeigniter.com/forumdisplay.php?fid=22) +--- Thread: Simple database CRUD for Codeigniter (/showthread.php?tid=54971) |
Simple database CRUD for Codeigniter - El Forum - 10-03-2012 [eluser]keevitaja[/eluser] I wrote a simple database abstraction layer to work with database tables. Simple Crud @ GitHub PHP 5.3 required Simple CRUD is very simple (it really cannot be more simpler) "database abstraction layer" for CodeIgniter, which gives you some additional benefits. Setup To create a new model extend it from Simple_crud instead of CI_Model. Both Simple_crud and your model must be loaded in CI way. Name your models <Table_name>_model. If you do not like "_model" in all model names, just remove preg_replace from __construct() method. If table name is example, then model would look Code: class Example_model extends Simple_crud {} Usage examples Table: example Fields: id, cats, dogs Model: Example_model Code: // Insert a row: Code: // Fetch a row: Code: // Update a row: Code: // Delete a row: Code: // All together: create, retrieve, update and delete. lol In Example_model you can add your own custom methods as it was the regular CodeIgniter model. Please feel free to use it any way you like! Simple database CRUD for Codeigniter - El Forum - 10-15-2012 [eluser]elite-board[/eluser] very cool, was looking for something just like this ![]() thanks. |