1. Go to this page and download the library: Download thomas-institut/datatable 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/ */
thomas-institut / datatable example snippets
$newRow = [ 'field1' => 'exampleStringValue', // or
'field2' => null,
'field3' => true, // or false
'field4' => $someIntegerVariable
// ...
'fieldN' => $nthValue ];
$newId = $dt->createRow($newRow);
// $newId is unique within the table
$rows = $dt->getAllRows();
$numRows = $rows->count();
// EITHER
foreach($rows as $row) {
// do something ...
}
// OR
$firstRow = $rows->getFirst(); // null if there are no rows in the result set
public function search(array $searchSpecArray, int $searchType = self::SEARCH_AND, int $maxResults = 0) : array;
/**
* Searches the datatable according to the given $searchSpec
*
* $searchSpecArray is an array of conditions.
*
* If $searchType is SEARCH_AND, the row must satisfy:
* $searchSpecArray[0] && $searchSpecArray[1] && ... && $searchSpecArray[n]
*
* if $searchType is SEARCH_OR, the row must satisfy the negation of the spec:
*
* $searchSpecArray[0] || $searchSpecArray[1] || ... || $searchSpecArray[n]
*
*
* A condition is an array of the form:
*
* $condition = [
* 'column' => 'columnName',
* 'condition' => one of (EQUAL_TO, NOT_EQUAL_TO, LESS_THAN, LESS_OR_EQUAL_TO, GREATER_THAN, GREATER_OR_EQUAL_TO)
* 'value' => someValue
* ]
*
* Notice that each condition type has a negation:
* EQUAL_TO <==> NOT_EQUAL_TO
* LESS_THAN <==> GREATER_OR_EQUAL_TO
* LESS_OR_EQUAL_TO <==> GREATER_THAN
*
* if $maxResults > 0, an array of max $maxResults will be returned
* if $maxResults <= 0, all results will be returned
public function findRows(array $rowToMatch, int $maxResults = 0) : array;
$dt->updateRow($row);
// OR
$dt[$rowId] = $row;
$result = $dt->deleteRow($rowId);
// OR
unset($dt[$rowId]);
$supported = $dt->supportsTransactions(); // true if supported
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.