esclaudio/datatables

Simple server side processing for datatables

1.1.0 2022-01-22 19:51 UTC

This package is auto-updated.

Last update: 2024-05-23 00:45:37 UTC


README

Latest Version on Packagist GitHub Tests Action Status Total Downloads

Installation

You can install the package via composer:

composer require esclaudio/datatables

Usage

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": {...}}

Testing

composer test

Changelog

Please see CHANGELOG for more information on what has changed recently.

License

The MIT License (MIT). Please see License File for more information.