Automatic CodeIgniter Create Replace Update Delete
ACICRUD, is a library for CodeIgniter that provides a fully automatic CRUD for your models.
The library allows you to create, read, update, or delete database rows without write any line of code.
It provides also a collection of method that can be usefull for database manipulation. Acicrud support multi database connections since 1.1 version.
ACICRUD by ACICRUD is licensed under a Creative Commons Attribution-Noncommercial-Share Alike 3.0 United States License.
Permissions beyond the scope of this license may be available at https://nukium.com/.
ACICRUD requires PHP 5 and CodeIgniter 1.6.3 minimum (untested with older versions). The library is fully compatible with CodeIgniter 2.0.x.
ACICRUD installation process is identical to all single file library for CodeIgniter :
- Download the archive
- Extract Acicrud.php in libraries folder of your application (/application/libraries)
- Add Acicrud to the autoload libraries list via the autoloader (optional)
- Install is finished ! Your models can now extend the class Acicrud.
ACICRUD can be seen than a « meta-model » for CodeIgniter, actually, the class extends the Model class of CodeIgniter. That’s why all your model will have to extend Acicrud instead of Model in order to use it.
Be carefull, in order to use ACICURD, your database tables need to be at least in 1NF.
This API is currently being drafted, you can found below the main methods of the Acicrud class. Notes that most of methods use PHP native exceptions.
- Object read(int $id) : Read a row in the database and return an object. An associative array can be given to the read() method instead of a numeric ID in order to read one entry with a custom WHERE clause (require v1.1).
- Object readLast() : Try to read the latest entry in the table then return an object.
- void create(Object $o) : Create a row in the database from an object. It’s not necessary to define all the table fields in the Object. Returns the numeric id of the inserted row.
- void delete(int $id) : Delete a database row identified by its id.
- void update(Object $o) : Update a database row from an object, can be called after read() without providing the object id (primary key).
- mixed getAll(int $limit = null, array $order = null, array $where = null) : Return a collection of rows. $limit and $order can be used to limit/sort the rows. $where can be used to generate the WHERE clauses.
- mixed get(mixed $what, int $id) : Return a row field identified by the row id in the database.
- mixed getBy(mixed $by, mixed $value) : Select elements with the $by field that have the $value value.
- mixed getter(mixed $what) : Simple getter used after the read of a row.
- int countAll(array $where) : Return the number of table rows. An associative array can be given in order to use a custon WHERE clause.
- int lastId() : Return the last inserted ID by Acicrud or by the DBMS if the first one doesn’t exist.
- int getMaxId() : Return the largest currently used ID in the table or 0 if the table is empty.
- void checkId(int $id) : Check a row id in the database. Throw an exception CHECK_ID_TABLE_FAILLURE in case of error.
- Collection result() : Run the Active Record Query an return an array of Objects.
- Object row() : Run the Active Record Query an return one result Object.
- Void debug(Boolean $executeQuery = true, Boolean $die = true) : Stop the script execution in displaying the last query done by the database class. Breaking of execution script can be prevent by givin false to the second parameter.
Tutorials still in french for the moment, but comments are written in english 😉
- Installation of Acicrud
- Reading data with Acicrud
- Inserting data with Acicrud
- Deleting data with Acicrud
- Adding custom methods to your models
- Multi database support
- Call to a member function result_array() on a non-object in /system/database/DB_driver.php on line 837
Since the 12/30/2009, Acicrud is available in a stable and fully tested version that is currently used in production environment by more than 15 web applications over the Web.
- 2011-03-21: Acicrud-b6602b8889da7f18519a07678a5c935a4b118371.zip (v1.2)
- 2010-05-05: Acicrud-0c28279ee917f5c37007072c090f2bbfb8795e62.zip (v1.1)
- 2009-12-30: Acicrud-86ef21a05a4c9697ae01fb9b17736ef24704cbf8.zip (v1.0)
- 2009-05-17: Acicrud-81c77e249d3852ab7e04580955410e61c89d7d34.zip
- 2009-05-08: Acicrud-5b2f33362f587cc3c253846bf776dc409ee8f158.zip
I really need feedback and code review, so people please give me feedback here 😉