2017 © Pedro Peláez
 

library datatablesphp

PHP DataTables wrapper class for DataTables.js (Html and/or Javascript generation, Server-Side SQL) .

image

ropendev/datatablesphp

PHP DataTables wrapper class for DataTables.js (Html and/or Javascript generation, Server-Side SQL) .

  • Monday, April 13, 2015
  • by RobinD
  • Repository
  • 8 Watchers
  • 21 Stars
  • 5,588 Installations
  • PHP
  • 1 Dependents
  • 0 Suggesters
  • 8 Forks
  • 3 Open issues
  • 8 Versions
  • 1 % Grown

The README.md

DataTablesPHP : PHP class to easily use DataTables.js

Build Status Total Downloads, (*1)

Table of contents

Description

DataTablesPHP generates easily your DataTable Html or Javascript... with Server-Side or not. It enhances the filters's utilisation adding individual column filtering (with or without server-side)., (*2)

Compatible with the last version of DataTables (1.10.x)., (*3)

Features

  • Generate html table (complex header)
  • Generate the Javascript related (Data can be set in the initial parameters or load via Ajax or Server-Sive)
  • Custom search column by column and complex search to optimize SQL queries
  • Analyze Server-Side Request and Generate SQL queries
    • Can handle complex query (join)
    • Can handle Optimize Query to search value (not only Like %, you can parameter to use =,,,=,=,BETWEEN...)
  • Using all this features in the same time permits to easily handle a dataTable with PHP

Server-side part inspired from Allan Jardine's Class SSP. Improve in order to don't trust user input, add the join possibilities and more..., (*4)

Installation

You can clone this git, download the class or use Composer :, (*5)

composer require ropendev/datatablesphp

Example

See in the examples folder., (*6)

Documentation

DataTable::instance('id')
    ->setJsInitParam($key, $value)           // http://datatables.net/reference/option/
    ->setJsInitParams($params)               // To set all params in one time
    ->setDom($dom)                           // Alias for setJsInitParameter('dom', $dom)
    ->setColumn($params, $show = true)       // Add a column and there options to the table:
                                             // - Initialization Javascript Options (see the doc : DataTables.net > Refererences > Column)
                                             //  - PHP Options (parent for complex header, sFilter, sql_table, sqlFilter... see l.169)
                                             // if($show) will be printed in the table else will only be load via ajax
    ->setColumns($columns)                   // Add columns
    ->setServerSide($ajax)                   // http://datatables.net/reference/option/ajax
    ->setAjax($ajax)                         // Alias for setJsInitParameter('ajax', $ajax)
    ->setFilters($ajax)                      // Set permanent filters for sql queries (where)
    ->setData($data)                         // Permit to set the data in the DataTables Javascript Initialization.
    ->setHeader($bool)                       // To generate thead when you will call getHtml
    ->setFooter($bool)                       // To generate tfoot with th empty when you will call getHtml.
                                             // ... automatically called if you have set individual column filters


DataTable::instance('id')->getJavascript();  // Return javascript string. It is not embeding JS Files from DataTables.js... only it activation
                                            // and individual column filtering stuff

DataTable::instance('id')->getHtml([array('class'=>'my_table_class', 'data-nuclear'=>'bomb')]);        // Return html table in a string

/*** Server-Side Functions ***/
# You can't use server side options if you didn't set Columns

DataTable::instance('id')
    ->setFrom($table)                                                                                                 // Name of the table to query
    ->setJoin('table2', array('table'=>'column', 'table2'=>'column2') [, $join = 'LEFT JOIN', $duplicate = false])    // Table to join
    ->setPdoLink($pdoLink)                                                                                            // Add PHP PDO class link
    ->setCounterActive(false)  // Disabled counters (permits to gain in performanche, think to change your infoFiltered)

DataTable::instance('id')->exec($_REQUEST[, $csv = false]);  // Output the json results
                                                             //or export to csv format (use setInitFilter before if you use Individual column Filters)
DataTable::instance('id')->sendFatal($error);                // Output an error

A php array for a column can contain : * Properties for Initialization Javascript (see self::$columnParams or http://datatables.net/reference/option/) * parent (=>$title) : To have a complex header with a colspan... Set the same $title to put multiple column under the same th * sFilter (=>array) : for the column filtering options (see self::$columFilteringParams) * SQL params (sql_name and sql_table) : if there is different from data or default table set with setFrom * alias : sql alias (not required) * formatter (=>function($columnValue,$rowValues,$columnParams)) : if you want to print your data with a special format, set a function In a Server-Side Request, if you don't want select a SQL column, just don't set sql_name or data properties (but set a formatter function to print something !)., (*7)

License

MIT (see the LICENSE file for details), (*8)

Todo

It will come soon : * AutoGenerate select's options if there is data (l.469) * Example with export function, (*9)

The Versions

13/04 2015

dev-master

9999999-dev http://www.robin-d.fr/DataTablesPHP/

PHP DataTables wrapper class for DataTables.js (Html and/or Javascript generation, Server-Side SQL) .

  Sources   Download

MIT

The Requires

 

The Development Requires

datatables html table framework agnostic jquery table datatables.js

07/01 2015

0.0.95

0.0.95.0 http://www.robin-d.fr/DataTablesPHP/

PHP DataTables wrapper class for DataTables.js (Html and/or Javascript generation, Server-Side SQL) .

  Sources   Download

MIT

The Requires

 

The Development Requires

datatables html table framework agnostic jquery table datatables.js

06/01 2015

0.0.94

0.0.94.0 http://www.robin-d.fr/DataTablesPHP/

PHP DataTables wrapper class for DataTables.js (Html and/or Javascript generation, Server-Side SQL) .

  Sources   Download

MIT

The Requires

 

The Development Requires

datatables html table framework agnostic jquery table datatables.js

03/01 2015

0.0.93

0.0.93.0 http://www.robin-d.fr/DataTablesPHP/

PHP DataTables wrapper class for DataTables.js (Html and/or Javascript generation, Server-Side SQL) .

  Sources   Download

MIT

The Requires

 

The Development Requires

datatables html table framework agnostic jquery table datatables.js

02/12 2014

dev-dev

dev-dev http://www.robin-d.fr/DataTablesPHP/

PHP DataTables wrapper class for DataTables.js (Html and/or Javascript generation, Server-Side SQL) .

  Sources   Download

MIT

The Requires

 

The Development Requires

datatables html table framework agnostic jquery table datatables.js

02/12 2014

0.0.92

0.0.92.0 http://www.robin-d.fr/DataTablesPHP/

PHP DataTables wrapper class for DataTables.js (Html and/or Javascript generation, Server-Side SQL) .

  Sources   Download

MIT

The Requires

 

The Development Requires

datatables html table framework agnostic jquery table datatables.js

10/11 2014

0.0.91

0.0.91.0 http://www.robin-d.fr/DataTablesPHP/

PHP DataTables wrapper class for DataTables.js (Html and/or Javascript generation, Server-Side SQL) .

  Sources   Download

MIT

The Requires

  • php >=5.3.0

 

by Avatar robin

datatables html table jquery table datatables.js

06/11 2014

0.0.9

0.0.9.0 http://www.robin-d.fr/DataTablesPHP/

PHP DataTables wrapper class for DataTables.js (Html and/or Javascript generation, Server-Side SQL) .

  Sources   Download

MIT

The Requires

  • php >=5.3.0

 

by Avatar robin

datatables html table jquery table datatables.js