Datatables Php Library Star

Handles server-side processing for Datatables, in a fast and simple way !

Features

  • Easy to use. Generates json using only a few lines of code.
  • Editable columns with a closure function.
  • Supports custom filters.
  • Can handle most complicated queries.
  • Supports mysql and sqlite for native php.
  • Works with:
    • Laravel
    • CodeIgniter 3
    • Phalcon 3+
    • Prestashop
    • PostgreSql

Installation

Note: v2.0+ requires php 7.1.3+

Composer is required to install the library.

            composer require ozdemir/datatables
            copy
        

Methods

This is the list of available public methods.

query($query)required
  • sets the sql query

generate()required
  • runs the queries and builds the output
  • returns the output as json
  • same as generate()->toJson()

toJson()
  • returns the output as json
  • should be called after generate()

toArray()
  • returns the output as array
  • should be called after generate()

add($column, function($row){})
  • adds extra columns for custom usage

edit($column, function($row){})
  • allows column editing

filter($column, function(){})
  • allows custom filtering
  • has these methods:
    • escape($value)
    • searchValue()
    • defaultFilter()
    • between($low, $high)
    • whereIn($array)
    • greaterThan($value),
    • lessThan($value)

hide($columns)
  • removes the column from output
  • It is useful when you only need to use the data in add() or edit() methods.

setDistinctResponseFrom($column)
  • executes the query with the given column name and adds the returned data to the output with the distinctData key.

setDistinctResponse($output)
  • adds the given data to the output with the distinctData key.

getColumns()
  • returns column names (for dev purpose)

getQuery()
  • returns the sql query string that is created by the library (for dev purpose)