\SSP

Summary

Methods
Properties
Constants
data_output()
limit()
order()
filter()
simple()
sql_connect()
sql_exec()
fatal()
bind()
pluck()
No public properties found
No constants found
No protected methods found
No protected properties found
N/A
No private methods found
No private properties found
N/A

Methods

data_output()

data_output(array  $columns, array  $data) : array

Create the data output array for the DataTables rows

Parameters

array $columns

Column information array

array $data

Data from the SQL get

Returns

array —

Formatted data in a row based format

limit()

limit(array  $request, array  $columns) : string

Paging

Construct the LIMIT clause for server-side processing SQL query

Parameters

array $request

Data sent to server by DataTables

array $columns

Column information array

Returns

string —

SQL limit clause

order()

order(array  $request, array  $columns) : string

Ordering

Construct the ORDER BY clause for server-side processing SQL query

Parameters

array $request

Data sent to server by DataTables

array $columns

Column information array

Returns

string —

SQL order by clause

filter()

filter(array  $request, array  $columns, array  $bindings,   $dsphinXArrayParam = NULL) : string

Searching / Filtering

Construct the WHERE clause for server-side processing SQL query.

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 performance on large databases would be very poor

Parameters

array $request

Data sent to server by DataTables

array $columns

Column information array

array $bindings

Array of values for PDO bindings, used in the sql_exec() function

$dsphinXArrayParam

Returns

string —

SQL where clause

simple()

simple(array  $request, string  $table, string  $primaryKey, array  $columns,   $dsphinXArrayParam = NULL) : array

Perform the SQL queries needed for an server-side processing requested, utilising the helper functions of this class, limit(), order() and filter() among others. The returned array is ready to be encoded as JSON in response to an SSP request, or can be modified if needed before sending back to the client.

Parameters

array $request

Data sent to server by DataTables

string $table

SQL table to query

string $primaryKey

Primary key of the table

array $columns

Column information array

$dsphinXArrayParam

Returns

array —

Server-side processing response array

sql_connect()

sql_connect() : resource

Connect to the database

Returns

resource —

Database connection handle

sql_exec()

sql_exec(resource  $db, array  $bindings, string  $sql = null) : array

Execute an SQL query on the database

Parameters

resource $db

Database handler

array $bindings

Array of PDO binding values from bind() to be used for safely escaping strings. Note that this can be given as the SQL query string if no bindings are required.

string $sql

SQL query to execute.

Returns

array —

Result from the query (all rows)

fatal()

fatal(string  $msg) 

Throw a fatal error.

This writes out an error message in a JSON string which DataTables will see and show to the user in the browser.

Parameters

string $msg

Message to send to the client

bind()

bind(  $a, \*  $val, integer  $type) : string

Create a PDO binding key which can be used for escaping variables safely when executing a query with sql_exec()

Parameters

$a
\* $val

Value to bind

integer $type

PDO field type

Returns

string —

Bound key to be used in the SQL where this parameter would be used.

pluck()

pluck(array  $a, string  $prop) : array

Pull a particular property from each assoc. array in a numeric array, returning and array of the property values from each item.

Parameters

array $a

Array to get data from

string $prop

Property to read

Returns

array —

Array of property values