Automatic CodeIgniter Create Replace Update Delete

world_go Voir cette page en français.

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.


  1. Overview
  2. Licence
  3. Installation
  4. Operating principle
  5. API
  6. Tutorials
  7. Troubleshooting
  8. Download
  9. Feedback


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

Creative Commons License


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 :

  1. Download the archive
  2. Extract Acicrud.php in libraries folder of your application (/application/libraries)
  3. Add Acicrud to the autoload libraries list via the autoloader (optional)
  4. Install is finished ! Your models can now extend the class Acicrud.

Operating principle

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 😉

  1. Installation of Acicrud
  2. Reading data with Acicrud
  3. Inserting data with Acicrud
  4. Deleting data with Acicrud
  5. Adding custom methods to your models
  6. Multi database support


  1. 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.


I really need feedback and code review, so people please give me feedback here 😉