PHP code example of designbymalina / datatables-app

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

    

designbymalina / datatables-app example snippets


$appDb = new Database(/* host, user, pass, db */);
$dbAdapter = new DatabaseAdapter($appDb);

$config = new BlogConfigDataTable($dbAdapter);

use App\Controller\DemoController;
use Dbm\DataTables\Src\Renderers\DataTableRenderer;

// === Run ===
$demo = new DemoController();
extract($demo->run());

// === Render ===
$datatableRenderer = new DataTableRenderer();
echo $datatableRenderer->renderDataTable(
    $dt_records,
    $dt_sider,
    $dt_config
);

public function run(): array
{
    $params = $this->request->getQueryParams();
    $dtParams = $this->datatableParams->fromRequest($params);

    $dtResult = $this->dataTable
        ->withParams($dtParams)
        ->paginate($this->configDataTable);

    return [
        'dt_records' => $dtResult->records,
        'dt_sider' => $dtResult->sider,
        'dt_config' => $this->configDataTable,
        'dt_mode' => $this->configDataTable->getMode(),
        'dt_url' => $this->configDataTable->getUrl(),
        'dt_query' => $this->configDataTable->getLastBuiltQuery(),
    ];
}