承接 esdeathlove/datatables 相关项目开发

从需求分析到上线部署,全程专人跟进,保证项目质量与交付效率

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

esdeathlove/datatables

最新稳定版本:1.6.8

Composer 安装命令:

composer require esdeathlove/datatables

包简介

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

README 文档

README

Latest Stable Version Build Status license ![Gitter](https://badges.gitter.im/Join Chat.svg)

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

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 laravel and codeigniter3

How to install?

Installation via composer is supported.

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": "1.*"
    }
}

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.

How to use?

A simple ajax example:

    <?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 : string ) (required)
  • edit ($column:string, Closure:object ) (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';
    });

    echo $dt->generate();

Requirements

DataTables > 1.10
PHP > 5.3.7

License

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

统计信息

  • 总下载量: 138.1k
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 0
  • 点击次数: 0
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 0
  • Watchers: 1
  • Forks: 85
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2017-02-18