Introduction
Core class for handling CRUD operations and rendering views
The Besc_crud
class provides functionality for creating, reading, updating and deleting database records, as well as rendering views for listing and editing data.
Properties
CodeIgniter instance
Database name
Database table name
Primary key column name
Array of column definitions
Array of column names to show in list view
Array of column names to allow filtering on
Title for the CRUD views
Base URL for CRUD operations
Methods
__construct()
Constructor method. Initializes CodeIgniter dependencies.
execute($per_page = ROWS_PER_PAGE_OF_TABLE)
Main method to handle CRUD operations based on the current state.
Number of rows per page for list view
render_list($ajax = false)
Renders the list view.
Whether this is an AJAX request
render_edit()
Renders the edit view for adding or editing a record.
delete()
Deletes a record.
insert()
Inserts a new record.
update()
Updates an existing record.
validate()
Validates submitted form data.
imageupload()
Handles image file uploads.
fileupload()
Handles general file uploads.
imagecrop()
Crops an uploaded image.
Usage
This initializes a CRUD interface for the “users” table. The execute()
method handles the current operation (list, add, edit, etc) and returns the appropriate view.