I’m wondering if Code Igniter has something equivalent to a small framework I built, and what it might be called. I built a small framework that creates a list view and edit view for each mysql database table. Below shows an example of code of how I might set up a CMS to manipulate a database table:
// CODE FOR LIST VIEW - http://mysite.com/admin/user.php
// This code will output an html table of records from db table t_user.
// The html table will have controls that allow user to search, delete, and paginate
// You can click on each record to edit the record
<?php
include('class/framework.php');
$template = new ListView();
$template->data_object = new DB($mysql_table_name = 't_user');
$template->setCol($col = 'user_name', $label = 'User Name');
$template->setCol($col = 'email', $label = 'Email');
$template->setCol($col = 'last_login', $label = 'Last Time Logged In', $format='Y-m-d H:i:s');
$tempate->run();
?>
// CODE FOR EDIT VIEW - http://mysite.com/admin/user.edit.php
// This code will output an html form that adds, edits, deletes
// and validates a record from t_user
<?php
include('class/framework.php');
$template = new EditView();
$template->data_object = new DB($mysql_table_name = 't_user'):
$f = new Field($col = 'user_id', $type = 'hidden');
$template->field[] = $f;
$f = new Field($col = 'email', $type = 'text');
$f->arr_validate = array('is_email', 'is_required');
$template->field[] = $f;
$f = new Field($col = 'phone', $type = 'text');
$f->arr_validate = array('is_phone', 'is_required');
$template->field[] = $f;
$f = new Field($col = 'password', $type = 'password');
$template->field[] = $f;
$f = new Field($col = 'bio', $type = 'wysiwyg');
$template->field[] = $f;
$f = new Field($col = 'pic', $type = 'image');
$template->field[] = $f;
$template->run();
?>
And that’s it…I don’t have to write a single line of html, css or javascript code. All the validation is done for me as long as I populate $f->arr_validate. The ability to search, sort, paginate, edit, delete etc…is all done with just the code above.
Is there something in Code Igniter that achieves something similar? If there is no such thing out of the box, just say so.
What you’re looking for is known as a CRUD as opposed to a CMS.
C – Create
R – Read
U – Update
D – Delete
I strongly recommend Grocery Crud for this purpose. It’s great and very easy to set up. Incorporates the features you’re looking for such as pagination and search etc.