PHP code example of esclaudio / datatables

1. Go to this page and download the library: Download esclaudio/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/ */

    

esclaudio / datatables example snippets

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