<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
neighborhoods / snowflake-sql-api-component example snippets
php
use Neighborhoods\SnowflakeSqlApiComponent\SingleStatementClientV1;
/** @var SingleStatementClientV1\ClientInterface $client */
$rows = $client->execute("SELECT 'Hello World!' as text_field, 1 as int_field");
foreach ($rows as $row) {
foreach ($row as $columnName => $columnValue) {
echo $columnName . ': ' . $columnValue . PHP_EOL;
}
}
php
use Neighborhoods\SnowflakeSqlApiComponent\SingleStatementClientV1;
/** @var SingleStatementClientV1\ClientInterface $client */
$rows = $client->execute("SELECT CONCAT('Hello ', ?, '!') as \"text_field\", ? as \"int_field\"", ['Again', 5]);
foreach ($rows as $row) {
foreach ($row as $columnName => $columnValue) {
echo $columnName . ': ' . $columnValue . PHP_EOL;
}
}
php
use Neighborhoods\SnowflakeSqlApiComponent\SingleStatementClientV1;
/** @var SingleStatementClientV1\ClientInterface $client */
$generator = $client->executePaginated("
WITH RECURSIVE NumberSequence (n, long_text_field) AS (
SELECT 1 AS n, 'Lorem ipsum dolor sit amet' as long_text_field
UNION ALL
SELECT n + 1, concat(long_text_field, ', Lorem ipsum dolor sit amet') FROM NumberSequence WHERE n < 100000
)
SELECT n FROM NumberSequence ORDER BY n");
foreach ($generator as $page) {
echo 'Page starts with ' . $page[0]['N'] . ' and ends with ' . end($page)['N'] . PHP_EOL;
}
php
use Neighborhoods\SnowflakeSqlApiComponent\ClientV1;
$jwtTokenGenerator = (new ClientV1\JwtTokenGenerator())
->setAccount('snowflake_account')
->setUser('snowflake_user')
->setPrivateKey(file_get_contents('~/path/snowflake_private_key.pem'));
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.