Giter Club home page Giter Club logo

ssp's Introduction

Customized SSP Class For Datatables Library

SSP is a Server Side Processing class for Datatables Library v1.10.0. I have customized it for include JOIN, Extra condition and Rename acceptance within query.

While using Datatables with complex query, I faced problem like these

  • Get Data from Multiple table not supported via Joining.
  • Extra Where, except filtering was not possible.
  • During work on Multiple Table, to avoid Duplicate key was not possible.

So due to allow complex query, I have changed the SSP class like my own. What i made changes are

  • I have added option to ADD JOIN Query and make necessary changes.
  • I have changed Column ARRAY format to handle get data from multiple table. Add TWO new index for complex query handle.
  • Add Extra Where condition through SSP Class.
  • You can Group by the result via sending Query through simple function of SSP Class.
  • You can use Having as well same like Group By

New formatted COLUMN Array

$columns = array(
    array( 'db' => '`c`.`id`',       'dt' => 0, 'field' => 'id' ),
    array( 'db' => '`c`.`login`',    'dt' => 1  'field' => 'login' ),
    array( 'db' => '`c`.`password`', 'dt' => 2, 'field' => 'password' ),
    array( 'db' => '`c`.`name`',     'dt' => 3, 'field' => 'client_name', 'as' => 'client_name' ),
    array( 'db' => '`cn`.`name`',    'dt' => 4, 'field' => 'currency_name','as' => 'currency_name' )

    array( 'db' => '`c`.`id_client`', 'dt' => 5, 'formatter' => function( $d, $row ) {
                return '<a href="EDIT_URL"><span class="label label-inverse"><i class="fa fa-edit"></i> Edit</span></a>';},
            'field' => 'id_client' )

How to Use

$joinQuery = "FROM `{$table}` AS `c` LEFT JOIN `currency_names` AS `cn` ON (`cn`.`id` = `c`.`id_currency`)";
$extraCondition = "`id_client`=".$ID_CLIENT_VALUE;

echo json_encode(
       SSP::simple( $_GET, $sql_details, $table, $primaryKey, $columns, $joinQuery, $extraCondition)
     );

I have described the changes at My personal blog. You can also check there to see details.

Hope it will help... Thanks

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.