2017 © Pedro PelĂĄez
 

library datatables

PHP Library to handle server-side processing for Datatables, in a fast and simple way.

image

iyuyue/datatables

PHP Library to handle server-side processing for Datatables, in a fast and simple way.

  • Sunday, May 20, 2018
  • by iYUYUE
  • Repository
  • 2 Watchers
  • 1 Stars
  • 6 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 33 Forks
  • 0 Open issues
  • 11 Versions
  • 50 % Grown

The README.md

Datatables library for PHP

Latest Stable Version Build Status license, (*1)

PHP Library to handle server-side processing for Datatables, in a fast and simple way. Live Demo, (*2)

Features

  1. Easy to use. Generates json using only a few lines of code.
  2. Editable columns with a closure function.
  3. Supports mysql and sqlite for native php.
  4. Works with :

How to install?

Installation via composer is supported., (*3)

If you haven't started using composer, I highly recommend you to use it., (*4)

Put a file named composer.json at the root of your project, containing this information:, (*5)

{
    "require": {
       "ozdemir/datatables": "1.*"
    }
}

And then run: composer install, (*6)

Or just run : composer require ozdemir/datatables, (*7)

Add the autoloader to your project:, (*8)

    <?php

    require_once 'vendor/autoload.php'

You're now ready to begin using the Datatables php library., (*9)

How to use?

A simple ajax example:, (*10)

    <?php
    require_once 'vendor/autoload.php';

    use Ozdemir\Datatables\Datatables;
    use Ozdemir\Datatables\DB\MySQL;

    $config = [ 'host'     => 'localhost',
                'port'     => '3306',
                'username' => 'homestead',
                'password' => 'secret',
                'database' => 'sakila' ];

    $dt = new Datatables( new MySQL($config) );

    $dt->query("Select film_id, title, description from film");

    echo $dt->generate();

Methods

This is the list of available public methods., (*11)

  • query ( $query : string ) (required)
  • add ($newColumn:string, Closure:object ) (optional)
  • edit ($column:string, Closure:object ) (optional)
  • get ($value:string ) (optional - for dev purpose)
  • hide ($column:mixed ) (optional)
  • generate ( ) (required)

Example

    <?php
    $dt = new Datatables( new MySQL($config) );

    $dt->query("Select id, name, email, address, plevel from users");

    $dt->edit('id', function($data){
        // return an edit link.
        return "<a href='user.php?id=" . $data['id'] . "'>edit</a>";
    });

    $dt->edit('email', function($data){
        // return mail@mail.com to m***@mail.com
        return preg_replace('/(?<=.).(?=.*@)/u','*', $data['email']);
    });

    $dt->edit('address', function($data){
        // check if user has authorized to see that
        $current_user_plevel = 4;
        if ($current_user_plevel > 2 && $current_user_plevel > $data['plevel']) {
            return $data['address'];
        }

        return 'you are not authorized to view this column';
    });

    $dt->add('action', function($data){
        // return an edit link in new column action
        return "<a href='user.php?id=" . $data['id'] . "'>edit</a>";
    });

    echo $dt->generate();

Requirements

DataTables > 1.10
PHP > 5.3.7, (*12)

License

Copyright (c) 2015 Yusuf ÖZDEMİR, released under the MIT license, (*13)

The Versions

20/05 2018

dev-master

9999999-dev

PHP Library to handle server-side processing for Datatables, in a fast and simple way.

  Sources   Download

MIT

The Development Requires

by Yusuf Özdemir

20/05 2018

1.6.9.1

1.6.9.1

PHP Library to handle server-side processing for Datatables, in a fast and simple way.

  Sources   Download

MIT

The Development Requires

by Yusuf Özdemir

14/02 2018

dev-2.0-dev

dev-2.0-dev

PHP Library to handle server-side processing for Datatables, in a fast and simple way.

  Sources   Download

MIT

The Requires

 

The Development Requires

by Yusuf Özdemir

20/12 2017

1.6.9

1.6.9.0

PHP Library to handle server-side processing for Datatables, in a fast and simple way.

  Sources   Download

MIT

The Development Requires

by Yusuf Özdemir

28/10 2017

1.6.8

1.6.8.0

PHP Library to handle server-side processing for Datatables, in a fast and simple way.

  Sources   Download

MIT

The Development Requires

by Yusuf Özdemir

25/09 2017

1.6.7

1.6.7.0

PHP Library to handle server-side processing for Datatables, in a fast and simple way.

  Sources   Download

MIT

The Development Requires

by Yusuf Özdemir

08/04 2017

1.6.6

1.6.6.0

PHP Library to handle server-side processing for Datatables, in a fast and simple way.

  Sources   Download

MIT

The Development Requires

by Yusuf Özdemir

09/03 2017

1.6.5

1.6.5.0

PHP Library to handle server-side processing for Datatables, in a fast and simple way.

  Sources   Download

MIT

The Development Requires

by Yusuf Özdemir

10/02 2017

1.6.4

1.6.4.0

PHP Library to handle server-side processing for Datatables, in a fast and simple way.

  Sources   Download

MIT

The Development Requires

by Yusuf Özdemir

07/01 2017

1.6.3

1.6.3.0

PHP Library to handle server-side processing for Datatables, in a fast and simple way.

  Sources   Download

MIT

The Development Requires

by Yusuf Özdemir

27/10 2016

1.6.0

1.6.0.0

Handles server-side processing for Datatables.

  Sources   Download

MIT

The Development Requires

by Yusuf Özdemir