/
githubmirror
/
ydb-php-sdk
Обзор
Документация
Войти
/
githubmirror
/
ydb-php-sdk
Код
Запросы
0
Пакеты
0
Релизы
0
Аналитика
Безопасность
main
src/Scripting.php
88 строк
2 KB
Alex Mironov
Separated grpc options to own section: `grpc`
12 апр 2024, 15:45
12 апр 2024, 15:45
f53126b
Код
Авторство
О чём код?
<?php namespace YdbPlatform\Ydb; use Psr\Log\LoggerInterface; use Ydb\Scripting\V1\ScriptingServiceClient as ServiceClient; class Scripting { use Traits\RequestTrait; use Traits\ParseResultTrait; use Traits\LoggerTrait; /** * @var ServiceClient */ protected $client; /** * @var array */ protected $meta; /** * @var LoggerInterface */ protected $logger; /** * @var Iam */ protected $credentials; /** * @param Ydb $ydb * @param LoggerInterface|null $logger */ public function __construct(Ydb $ydb, LoggerInterface $logger = null) { $this->ydb = $ydb; $this->client = new ServiceClient($ydb->endpoint(), $ydb->grpcOpts()); $this->meta = $ydb->meta(); $this->credentials = $ydb->iam(); $this->logger = $logger; } /** * @param string $script * @return bool|QueryResult * @throws \YdbPlatform\Ydb\Exception */ public function exec($script) { $result = $this->request('ExecuteYql', [ 'script' => $script, ]); return $result ? new QueryResult($result) : true; } /** * @param string $script * @return bool|mixed|void|null */ public function explain($script) { $result = $this->request('ExplainYql', [ 'script' => $script, ]); return $result; } /** * @param string $method * @param array $data * @return bool|mixed|void|null * @throws \YdbPlatform\Ydb\Exception */ protected function request($method, array $data = []) { return $this->doRequest('Scripting', $method, $data); } }