All Projects → n1crack → Datatables

n1crack / Datatables

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

Projects that are alternatives of or similar to Datatables

Ignition Go
Bootstrap4 /Codeigniter 3 Modular (HMVC) App Building Framework - to build enterprise class web applications... Versions: CodeIgniter 3.1.9 AdminLTE 3.4 Bootstrap 4.5.0
Stars: ✭ 166 (-10.27%)
Mutual labels:  mysql, laravel, codeigniter
Laravel
Muito conteúdo sobre o framework Laravel. Controllers, Models, Views, Blade, Migrations, Seeders, Middlewares, Autenticação, Autorização, Providers, pacotes, laravel 8, etc.
Stars: ✭ 43 (-76.76%)
Mutual labels:  mysql, sqlite, laravel
Serendipity
A PHP blog software
Stars: ✭ 151 (-18.38%)
Mutual labels:  mysql, sqlite
Tortoise Orm
Familiar asyncio ORM for python, built with relations in mind
Stars: ✭ 2,558 (+1282.7%)
Mutual labels:  mysql, sqlite
Atdatabases
TypeScript clients for databases that prevent SQL Injection
Stars: ✭ 154 (-16.76%)
Mutual labels:  mysql, sqlite
Ansipress
AnsiPress - Simple L(Linux) E(NGINX) M(MariaDB) P(PHP7) Shared Hosting Setup
Stars: ✭ 184 (-0.54%)
Mutual labels:  mysql, laravel
Laravel Db Profiler
Database Profiler for Laravel Web and Console Applications.
Stars: ✭ 141 (-23.78%)
Mutual labels:  mysql, laravel
Identity Card
A simple proof of identity card of the people's Republic of China.
Stars: ✭ 154 (-16.76%)
Mutual labels:  laravel, codeigniter
Goose
A database migration tool. Supports SQL migrations and Go functions.
Stars: ✭ 2,112 (+1041.62%)
Mutual labels:  mysql, sqlite
Rom Sql
SQL support for rom-rb
Stars: ✭ 169 (-8.65%)
Mutual labels:  mysql, sqlite
Linq2db
Linq to database provider.
Stars: ✭ 2,211 (+1095.14%)
Mutual labels:  mysql, sqlite
Easyappointments
Easy!Appointments is a highly customizable web application that allows customers to book appointments with you via a sophisticated web interface. Moreover, it provides the ability to sync your data with Google Calendar so you can use them with other services. It is an open source project that you can download and install even for commercial use. Easy!Appointments will run smoothly with your existing website as it can be installed in a single folder of the server and of course share an existing database.
Stars: ✭ 2,013 (+988.11%)
Mutual labels:  mysql, codeigniter
Sql Fundamentals
👨‍🏫 Mike's SQL Fundamentals and Professional SQL Courses
Stars: ✭ 140 (-24.32%)
Mutual labels:  mysql, sqlite
Dapper.linq
Dapper.Linq
Stars: ✭ 143 (-22.7%)
Mutual labels:  mysql, sqlite
Chyrp Lite
An ultra-lightweight blogging engine, written in PHP.
Stars: ✭ 131 (-29.19%)
Mutual labels:  mysql, sqlite
Genealogy
Laravel 8 and Vue family tree and genealogy data processing website.
Stars: ✭ 153 (-17.3%)
Mutual labels:  mysql, laravel
Databases
Async database support for Python. 🗄
Stars: ✭ 2,602 (+1306.49%)
Mutual labels:  mysql, sqlite
Querybuilderparser
A simple to use query builder for the jQuery QueryBuilder plugin for use with Laravel.
Stars: ✭ 126 (-31.89%)
Mutual labels:  laravel, datatables
Kangaroo
SQL client and admin tool for popular databases
Stars: ✭ 127 (-31.35%)
Mutual labels:  mysql, sqlite
Manage Fastapi
🚀 CLI tool for FastAPI. Generating new FastAPI projects & boilerplates made easy.
Stars: ✭ 163 (-11.89%)
Mutual labels:  mysql, sqlite

Datatables library for PHP

Latest Stable Version Build Status license

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

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 :

Installation

NOTE: version 2.0+ requires php 7.1.3+ (php supported versions)

The recommended way to install the library is with Composer

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

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

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

And then run:

composer install

Or just run :

composer require ozdemir/datatables

Add the autoloader to your project:

    <?php

    require_once 'vendor/autoload.php';

You're now ready to begin using the Datatables php library.

    <?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.

query($query) required

  • sets the sql query

generate() required

  • runs the queries and build outputs
  • 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
  • it has the methods below
    • 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)

Example

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

    use Ozdemir\Datatables\Datatables;
    use Ozdemir\Datatables\DB\SQLite;

    $path = __DIR__ . '/../path/to/database.db';
    $dt = new Datatables( new SQLite($path) );

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

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

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

    $dt->edit('address', function($data){
        // checks user access.
        $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->hide('plevel'); // hides 'plevel' column from the output

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

    $dt->filter('age', function (){
        // applies custom filtering.
        return $this->between(15, 30);
    });

    echo $dt->generate()->toJson(); // same as 'echo $dt->generate()';

Road Map

  • better test suites for each class
  • improve integrations for php frameworks

Requirements

Composer
DataTables > 1.10
PHP > 7.1.3

License

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

If you like the library

Buy Me A Coffee

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].