> ## Documentation Index
> Fetch the complete documentation index at: https://docs.getlecker.com/llms.txt
> Use this file to discover all available pages before exploring further.

# 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

<ResponseField name="ci" type="object">
  CodeIgniter instance
</ResponseField>

<ResponseField name="db_name" type="string">
  Database name
</ResponseField>

<ResponseField name="db_table" type="string">
  Database table name
</ResponseField>

<ResponseField name="db_primary_key" type="string">
  Primary key column name
</ResponseField>

<ResponseField name="db_columns" type="array">
  Array of column definitions
</ResponseField>

<ResponseField name="list_columns" type="array">
  Array of column names to show in list view
</ResponseField>

<ResponseField name="filter_columns" type="array">
  Array of column names to allow filtering on
</ResponseField>

<ResponseField name="title" type="string">
  Title for the CRUD views
</ResponseField>

<ResponseField name="base_url" type="string">
  Base URL for CRUD operations
</ResponseField>

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

<ParamField body="per_page" type="integer">
  Number of rows per page for list view
</ParamField>

### render\_list(\$ajax = false)

Renders the list view.

<ParamField body="ajax" type="boolean">
  Whether this is an AJAX request
</ParamField>

### 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

```php theme={null}
$crud = new Besc_crud();

$crud->table('users');
$crud->primary_key('id');
$crud->columns([
  'id' => ['type' => 'hidden'],
  'name' => ['type' => 'text'],
  'email' => ['type' => 'text']
]);

$output = $crud->execute();
```

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.
