PHP code example of openlss / lib-datatables

1. Go to this page and download the library: Download openlss/lib-datatables library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

openlss / lib-datatables example snippets


$obj = DataTables::_get()
	->setDB(Db::_get()) //add our database object
	->setDataModel('\BrowserModel')	//set datamodel to use for row formatting
	->setColumns(array('engine','browser','platform','version','grade')) //set column defs
	->setPrimary('id') //set primary column
	->setTable('table') //set sql table to use
	->setupFromRequest() //setup the object from $_REQUEST
	->process(); //process the request
echo $obj; //uses __toString to output json
exit;

$obj = DataTables::_get()
	->setDataCallback('my_data_function')
	->setDataModel('\BrowserModel')	//set datamodel to use for row formatting
	->setColumns(array('engine','browser','platform','version','grade')) //set column defs
	->setupFromRequest() //setup the object from $_REQUEST
	->process(); //process the request
echo $obj;
exit;

class BrowserModel extends \LSS\DataModel {
	//format version
	public function getVersion(){
		return empty($this->version) ? '-' : $this->version;
	}
}

$obj = new DataTables();

function my_callback_function($columns,$where,$order_by,$limit,$arg1,$arg2){
	//execute query here
	return array($results,$count_results,$count_total);
}