PHPackages                             openlss/lib-datatables - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Database &amp; ORM](/categories/database)
4. /
5. openlss/lib-datatables

ActiveLibrary[Database &amp; ORM](/categories/database)

openlss/lib-datatables
======================

PHP Interface for jQuery Datatables (http://datatables.net). Simple standalone, non-framework based.

0.0.2(13y ago)487LGPL-3.0+PHPPHP &gt;=5.3.2

Since May 7Pushed 13y ago4 watchersCompare

[ Source](https://github.com/nullivex/lib-datatables)[ Packagist](https://packagist.org/packages/openlss/lib-datatables)[ Docs](http://openlss.org)[ RSS](/packages/openlss-lib-datatables/feed)WikiDiscussions master Synced 2w ago

READMEChangelogDependencies (4)Versions (4)Used By (0)

openlss/lib-datatables
======================

[](#openlsslib-datatables)

PHP Interface for jQuery Datatables (). Simple standalone, non-framework based.

This document assumes you have a working datatables frontend. Just point it to the usage code below.

Usage
=====

[](#usage)

This is the standard usage which builds and executes queries on the provided Db object.

```
$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;
```

This is the alternative syntax where a Data Callback function is defined

```
$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;
```

openlss/lib-datamodels Usage
============================

[](#openlsslib-datamodels-usage)

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

Methods
=======

[](#methods)

### (object) DataTables::\_get()

[](#object-datatables_get)

Returns a new object same as

```
$obj = new DataTables();
```

### ($this) DataTables::setDB(\\LSS\\Db $obj)

[](#this-datatablessetdblssdb-obj)

Set the LSS\\Db object to call queries on

### ($this) DataTables::setColumns($array)

[](#this-datatablessetcolumnsarray)

Set the array of columns in the table (should match SQL names)

### ($this) DataTables::setPrimary($val)

[](#this-datatablessetprimaryval)

Set the primary column name (can be an array for multiple columns)

### ($this) DataTables::setTable($val)

[](#this-datatablessettableval)

Set the database table to use (can be multiple just separate with commas) NOTE: currently does not support joins

### ($this) DataTables::setDataCallback($callback,\[$arg1,$arg2...\])

[](#this-datatablessetdatacallbackcallbackarg1arg2)

Set the data callback function to provide data rather than direct DB querying The proper return is a 3-part array consisting of

- $result\_array The results in an array
- $count\_results Count of the results returned
- $count\_total Total count of records Example callback function

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

### ($this) DataTables::setDataModel($val)

[](#this-datatablessetdatamodelval)

Set the datamodel class to use. By Default uses \\LSS\\DataModel with no extensions

### ($this) DataTables::setParams($name,$val)

[](#this-datatablessetparamsnameval)

Store arbitrary params for use in resulting JSON

### (int) DataTables::getColumnCount()

[](#int-datatablesgetcolumncount)

Returns the number of columns set (caches the result for speed)

### (string) DataTables::getColumnByKey($key)

[](#string-datatablesgetcolumnbykeykey)

Returns the column name by index number

### (mixed) DataTables::getParam($key)

[](#mixed-datatablesgetparamkey)

Returns the value of a set param by name (key)

### (string) DataTables::getJSON()

[](#string-datatablesgetjson)

Returns JSON built from result array

### (array) DataTables::getResult()

[](#array-datatablesgetresult)

Return the built result array

### ($this) DataTables::setupFromRequest()

[](#this-datatablessetupfromrequest)

Sets up all the various portions needed for query generation from $\_REQUEST

### ($this) DataTables::setupPaging($start=null,$limit=null)

[](#this-datatablessetuppagingstartnulllimitnull)

Setup paging for SQL

### ($this) DataTables::setupOrdering((mixed...))

[](#this-datatablessetuporderingmixed)

Dynamic function for setting up ordering Argument format is:

- col\_number Number of columns
- col\_x\_sortable Is column sortable
- col\_x\_key Column number related to $this-&gt;columns
- col\_x\_sort\_dir Sort direction of the column

### ($this) DataTables::setupFiltering((mixed...))

[](#this-datatablessetupfilteringmixed)

NOTE this does not match the built-in DataTables filtering which does it word by word on any field. It's possible to do here, but concerned about efficiency on very large tables, and MySQL's regex functionality is very limited Dynamic function for setting up filtering Argument format is:

- search\_string User search string
- col\_x\_searchable Column ID that is searchable
- col\_x\_search\_string Individual search string per column

### ($this) DataTables::setupQueries()

[](#this-datatablessetupqueries)

Sets up SQL queries based on collected data

### ($this) DataTables::proces()

[](#this-datatablesproces)

Run queries and build result array

### (string) DataTables::\_\_toString()

[](#string-datatables__tostring)

Returns the resulting JSON when the object is used as a string

###  Health Score

25

—

LowBetter than 35% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity13

Limited adoption so far

Community8

Small or concentrated contributor base

Maturity50

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 100% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~0 days

Total

2

Last Release

4846d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/83c8e9d55e3ebafb0621a441a51af8f551f61a274fde5400459a29cc320b7b75?d=identicon)[nullivex](/maintainers/nullivex)

---

Top Contributors

[![nullivex](https://avatars.githubusercontent.com/u/2321375?v=4)](https://github.com/nullivex "nullivex (7 commits)")

---

Tags

mysqljqueryserver-sidedatatables.net

### Embed Badge

![Health badge](/badges/openlss-lib-datatables/health.svg)

```
[![Health](https://phpackages.com/badges/openlss-lib-datatables/health.svg)](https://phpackages.com/packages/openlss-lib-datatables)
```

###  Alternatives

[doctrine/dbal

Powerful PHP database abstraction layer (DBAL) with many features for database schema introspection and management.

9.7k614.3M7.3k](/packages/doctrine-dbal)[kirschbaum-development/eloquent-power-joins

The Laravel magic applied to joins.

1.6k35.7M51](/packages/kirschbaum-development-eloquent-power-joins)[scienta/doctrine-json-functions

A set of extensions to Doctrine that add support for json query functions.

58926.6M60](/packages/scienta-doctrine-json-functions)[cytopia/mysqldump-secure

Secure mysqldump script with encryption, compression, logging, blacklisting and Nagios monitoring integration

1484.7k1](/packages/cytopia-mysqldump-secure)[ark/database

Light weight database abstraction

117.8k](/packages/ark-database)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
