phpDocumentor

DataTableHelper
in package

Class DataTableHelper

This class contains helper methods for datatable manipulation. Create an instance and define the columns of your table and their respective database fields. You can also provide two fields separated with a space for concatenated string.

Tags
category

System

subpackage

Helpers

Table of Contents

getFilterParameters()  : array<string|int, mixed>
Get the filtering parameters of the request.
getOrderByClause()  : string
Get ORDER BY clause.
_trimArray()  : array<string|int, mixed>|string
Recursively trim the array values.

Methods

getFilterParameters()

Get the filtering parameters of the request.

public getFilterParameters(DataTableColumnCollection $columns) : array<string|int, mixed>

Notice: Multiple string values need to be sent as concatenated strings with "||" as the delimiter.

Parameters
$columns : DataTableColumnCollection

Contains the definitions of the table columns.

Tags
throws
InvalidArgumentException
Return values
array<string|int, mixed>

getOrderByClause()

Get ORDER BY clause.

public getOrderByClause(DataTableColumnCollection $columns) : string

This method will check the order parameter of the DataTables request and return the appropriate ORDER BY clause.

Notice: DataTables sends the zero-based index of the table column and not the name. If the column order changes then the method needs to be updated.

Parameters
$columns : DataTableColumnCollection

Contains the definitions of the table columns.

Tags
throws
Exception

If there is no order case for the provided column index.

throws
InvalidArgumentException
Return values
string

_trimArray()

Recursively trim the array values.

protected _trimArray(string|array<string|int, mixed> $entry) : array<string|int, mixed>|string
Parameters
$entry : string|array<string|int, mixed>
Return values
array<string|int, mixed>|string

Search results