1 Star 0 Fork 0

StatX/phpgsql

加入 Gitee
与超过 1400万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
克隆/下载
AsyncQuery.php 2.00 KB
一键复制 编辑 原始数据 按行查看 历史
Jakub Trmota 提交于 2025-08-18 06:03 +08:00 . CS: lowercase for true/false/null
<?php declare(strict_types=1);
namespace Forrest79\PhPgSql\Db;
class AsyncQuery
{
private Connection $connection;
private ResultBuilder $resultBuilder;
private AsyncHelper $asyncHelper;
private Query $query;
private string|null $preparedStatementName;
public function __construct(
Connection $connection,
ResultBuilder $resultBuilder,
AsyncHelper $asyncHelper,
Query $query,
string|null $preparedStatementName = null,
)
{
$this->connection = $connection;
$this->resultBuilder = $resultBuilder;
$this->asyncHelper = $asyncHelper;
$this->query = $query;
$this->preparedStatementName = $preparedStatementName;
}
public function getQuery(): Query
{
return $this->query;
}
/**
* @throws Exceptions\QueryException
*/
public function getNextResult(): Result
{
$actualAsyncQuery = $this->asyncHelper->getAsyncQuery();
$actualAsyncExecuteQuery = $this->asyncHelper->getAsyncExecuteQuery();
if (($actualAsyncQuery === null) && ($actualAsyncExecuteQuery === null)) {
throw Exceptions\ConnectionException::asyncNoQueryIsSent();
} else if (($actualAsyncQuery !== $this) || ($actualAsyncExecuteQuery !== null)) {
throw Exceptions\ConnectionException::anotherAsyncQueryIsRunning(
$this->getQuery()->sql,
$actualAsyncExecuteQuery ?? $actualAsyncQuery->getQuery()->sql,
);
}
$resource = \pg_get_result($this->connection->getResource());
if ($resource === false) {
$this->asyncHelper->clearQuery();
throw Exceptions\ResultException::noOtherAsyncResult($this->getQuery());
}
if (!$this->asyncHelper::checkAsyncQueryResult($resource)) {
if ($this->preparedStatementName === null) {
throw Exceptions\QueryException::asyncQueryFailed($this->getQuery(), (string) \pg_result_error($resource));
} else {
throw Exceptions\QueryException::asyncPreparedStatementQueryFailed(
$this->preparedStatementName,
$this->getQuery(),
(string) \pg_result_error($resource),
);
}
}
return $this->resultBuilder->build($resource, $this->getQuery());
}
}
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
PHP
1
https://gitee.com/statx/phpgsql.git
git@gitee.com:statx/phpgsql.git
statx
phpgsql
phpgsql
master

搜索帮助