You can install the package via composer:
composer require esclaudio/datatables
use Esclaudio\Datatables\Datatables;
use Esclaudio\Datatables\Options;
use Esclaudio\Datatables\Database\Connection;
$connection = new Connection(new \PDO(...));
$options = new Options($_GET);
header('Content-Type: application/json');
echo (new Datatables($connection, $options))
->from('posts')
->join('users', 'users.id', '=', 'posts.created_by')
->select([
'posts.id as id',
'posts.title as title',
'users.name as creator',
])
->toJson(); // {"draw": 1, "recordsTotal": 1, "recordsFiltered": 1, "data": {...}}
composer test
Please see CHANGELOG for more information on what has changed recently.
The MIT License (MIT). Please see License File for more information.