1. Go to this page and download the library: Download dimajolkin/ydb-php-sdk 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/ */
dimajolkin / ydb-php-sdk example snippets
use YandexCloud\Ydb\Ydb;
$config = [
// Database path
'database' => '/ru-central1/b1glxxxxxxxxxxxxxxxx/etn0xxxxxxxxxxxxxxxx',
// Database endpoint
'endpoint' => 'ydb.serverless.yandexcloud.net:2135',
// Auto discovery (dedicated server only)
'discovery' => false,
// IAM config
'iam_config' => [
'temp_dir' => './tmp', // Temp directory
'root_cert_file' => './CA.pem', // Root CA file (dedicated server only!)
// OAuth token authentication
'oauth_token' => 'AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA',
],
];
$ydb = new Ydb($config);
use YandexCloud\Ydb\Ydb;
$config = [
// ...
];
$ydb = new Ydb($config);
// obtaining the Table service
$table = $ydb->table();
// obtaining a session
$session = $table->session();
// making a query
$result = $session->query('select * from `users` limit 10;');
$users_count = $result->rowCount();
$users = $result->rows();
$columns = $result->columns();
$table = $ydb->table();
// making a query
$result = $table->query('select * from `users` limit 10;');
$session = $table->session();
// creating a new query builder instance
$query = $session->newQuery('select * from `users` limit 10;');
// a setting to keep in cache
$query->keepInCache();
// a setting to begin a transaction with the given mode
$query->beginTx('stale');
$result = $query->execute();
bash
composer
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.