PHP code example of raliable / ci4-datatables

1. Go to this page and download the library: Download raliable/ci4-datatables library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

raliable / ci4-datatables example snippets




namespace App\Controllers;

use \Raliable\DataTables\DataTables;
use CodeIgniter\API\ResponseTrait;

class DataTableController extends BaseController
{
    use ResponseTrait;

    public function index()
    {
    	return view('datatable_view');
    }

    public function ajax_list()
    {
        $config = [
            'table' => 'your_table_name',
        ];

        $datatables = new DataTables($config);
        $datatables->select('id, name, address, email')
                   ->join('another_table', 'another_table.foreign_key = your_table_name.id', 'left')
                   ->where('status', 1)
                   ->orderBy('id', 'asc');

        return $datatables->generate();
    }
}