PHP code example of kafkiansky / phpclick

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

    

kafkiansky / phpclick example snippets




declare(strict_types=1);

nt = new PHPClick\Client('http://127.0.0.1:8124/');

$client->insert(
    PHPClick\Query::string('INSERT INTO test.logs (LogName, LogTime, LogAttributes, LogUserId)'),
    PHPClick\Batch::fromRows(
        PHPClick\Row::columns(
            PHPClick\Column::string('users'),
            PHPClick\Column::dateTime64(new \DateTimeImmutable()),
            PHPClick\Column::map(
                [PHPClick\Column::string('x'), PHPClick\Column::string('y')],
            ),
            PHPClick\Column::nullable(
                PHPClick\Column::int64(13),
            ),
        ),
        PHPClick\Row::columns(
            PHPClick\Column::string('users'),
            PHPClick\Column::dateTime64(new \DateTimeImmutable()),
            PHPClick\Column::map(
                [PHPClick\Column::string('x'), PHPClick\Column::string('y')],
            ),
            PHPClick\Column::nullable(),
        ),
    ),
);



declare(strict_types=1);

ick\rowsToFile(
    __DIR__.'/click.log', // or resource
    PHPClick\Row::columns(
        PHPClick\Column::string('users'),
        PHPClick\Column::dateTime64(new \DateTimeImmutable()),
        PHPClick\Column::map(
            [PHPClick\Column::string('x'), PHPClick\Column::string('y')],
        ),
        PHPClick\Column::nullable(
            PHPClick\Column::int64(13),
        ),
    ),
    PHPClick\Row::columns(
        PHPClick\Column::string('users'),
        PHPClick\Column::dateTime64(new \DateTimeImmutable()),
        PHPClick\Column::map(
            [PHPClick\Column::string('x'), PHPClick\Column::string('y')],
        ),
        PHPClick\Column::nullable(),
    ),
);

$client = new PHPClick\Client('http://127.0.0.1:8124/');

$logHandle = fopen(__DIR__.'/click.log', 'r');

try {
    $client->insert(
        PHPClick\Query::string('INSERT INTO test.logs (LogName, LogTime, LogAttributes, LogUserId)'),
        PHPClick\Batch::fromStream($logHandle),
    );
} finally {
    if (\is_resource($logHandle)) {
        \fclose($logHandle);
    }
}



declare(strict_types=1);

nt = new PHPClick\Client('http://127.0.0.1:8124/');

$client->insert(
    PHPClick\Query::builder('test.logs')->columns(
        'LogName',
        'LogTime',
        'LogAttributes',
        'LogUserId',
    ),
    PHPClick\Batch::fromRows(/* rows here */),
);