CRUD CodeIgniter / ActiveRecord
CodeIgniter uses a modified version of the Active Record Database Pattern. This pattern allows information to be retrieved, inserted, and updated in your database with minimal scripting. In some cases only one or two lines of code are necessary to perform a database action. CodeIgniter does not require that each database table be its own class file. It instead provides a more simplified interface.
The model using Active Record calling
The view rendering what was passed in $data array : here it is $query
Let us examine another more complex CRUD sample using an array to configure tables names in config folder like that :
This will permit to write one ACL model for all tables :
A sample of two get functions using the call to config file :
More simple get and update functions in Models calls could be like below :
Now we can write an insert function in ACL controller like :
And we can write an edit function with validations rule in ACL controller like 2 parts below :
In this part of else we will write updates if rule validations are true