PHP code example of midorikocak / tabletools

1. Go to this page and download the library: Download midorikocak/tabletools 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/ */

    

midorikocak / tabletools example snippets




declare(strict_types=1);

namespace midorikocak\tabletools;

interface TableInterface
{
    public function sort(string $key, $order = 'ASC'): self;

    public function columns($keys): self;

    public function filter(string $key, $value): self;

    public function search(string $key, $value): self;

    public function range(int $offset, ?int $limit = null): self;

    public function paginate(int $page = 0, int $pageSize = 10): self;

    public function run(): array;
}

$pdo = new PDO();
$db = new \midorikocak\nanodb\Database($pdo);
$databaseTable = new \midorikocak\tabletools\DatabaseTable($db);

$data = getArrayFromCsv('tests/small-name.csv');
$arrayTable = new ArrayTable($data);

$csvTable = new CsvTable('tests/small-name.csv');

$columns = $this->arrayTable->columns(['first_name', 'last_name'])->run();

$filtered = $this->arrayTable->filter('username', 'midorikocak')->run();

$sorted = $this->arrayTable->sort('username', 'DESC')->run();

$found = $this->arrayTable->search('username', 'kocak')->run();

// Retrieves 10 items after 30th
$range = $this->arrayTable->range(30, 10)->run();

// Retrieves 50 more items after first 50 item. 
$page = $this->arrayTable->paginate(2, 50)->run();