2016-12-30 06:21:17 +01:00
|
|
|
<?php
|
2016-09-14 16:27:39 +02:00
|
|
|
|
|
|
|
namespace Amp\Postgres;
|
|
|
|
|
2017-06-21 05:17:53 +02:00
|
|
|
use Amp\CallableMaker;
|
|
|
|
use Amp\Coroutine;
|
|
|
|
use Amp\Deferred;
|
|
|
|
use Amp\Emitter;
|
|
|
|
use Amp\Loop;
|
|
|
|
use Amp\Promise;
|
2017-07-28 06:20:16 +02:00
|
|
|
use Amp\Success;
|
2016-09-14 16:27:39 +02:00
|
|
|
use pq;
|
2017-06-21 05:17:53 +02:00
|
|
|
use function Amp\call;
|
|
|
|
use function Amp\coroutine;
|
2016-09-14 16:27:39 +02:00
|
|
|
|
2017-08-01 07:38:12 +02:00
|
|
|
class PqHandle implements Handle {
|
2016-09-14 16:27:39 +02:00
|
|
|
use CallableMaker;
|
2017-05-16 06:28:37 +02:00
|
|
|
|
2016-09-14 16:27:39 +02:00
|
|
|
/** @var \pq\Connection PostgreSQL connection object. */
|
|
|
|
private $handle;
|
|
|
|
|
|
|
|
/** @var \Amp\Deferred|null */
|
2016-09-21 07:18:24 +02:00
|
|
|
private $deferred;
|
2017-05-16 06:28:37 +02:00
|
|
|
|
2017-07-27 07:32:34 +02:00
|
|
|
/** @var \Amp\Deferred|null */
|
2016-09-14 16:27:39 +02:00
|
|
|
private $busy;
|
|
|
|
|
|
|
|
/** @var string */
|
|
|
|
private $poll;
|
|
|
|
|
|
|
|
/** @var string */
|
|
|
|
private $await;
|
2017-05-16 06:28:37 +02:00
|
|
|
|
2017-01-18 18:05:05 +01:00
|
|
|
/** @var \Amp\Emitter[] */
|
2016-09-19 18:12:32 +02:00
|
|
|
private $listeners;
|
2016-09-14 16:27:39 +02:00
|
|
|
|
2017-07-28 06:20:16 +02:00
|
|
|
/** @var \Amp\Postgres\Internal\PqStatementStorage[] */
|
|
|
|
private $statements = [];
|
|
|
|
|
2016-09-14 16:27:39 +02:00
|
|
|
/** @var callable */
|
|
|
|
private $send;
|
2017-05-16 06:28:37 +02:00
|
|
|
|
2016-09-14 16:27:39 +02:00
|
|
|
/** @var callable */
|
|
|
|
private $fetch;
|
2017-05-16 06:28:37 +02:00
|
|
|
|
2016-09-19 18:12:32 +02:00
|
|
|
/** @var callable */
|
|
|
|
private $unlisten;
|
2017-05-16 06:28:37 +02:00
|
|
|
|
2016-09-14 16:27:39 +02:00
|
|
|
/** @var callable */
|
|
|
|
private $release;
|
2017-05-16 06:28:37 +02:00
|
|
|
|
2017-07-28 06:20:16 +02:00
|
|
|
/** @var callable */
|
|
|
|
private $deallocate;
|
|
|
|
|
2016-09-14 16:27:39 +02:00
|
|
|
/**
|
|
|
|
* Connection constructor.
|
|
|
|
*
|
|
|
|
* @param \pq\Connection $handle
|
|
|
|
*/
|
|
|
|
public function __construct(pq\Connection $handle) {
|
|
|
|
$this->handle = $handle;
|
2017-05-16 06:28:37 +02:00
|
|
|
|
2017-11-05 22:38:17 +01:00
|
|
|
$handle = &$this->handle;
|
2016-09-21 07:18:24 +02:00
|
|
|
$deferred = &$this->deferred;
|
|
|
|
$listeners = &$this->listeners;
|
2017-05-16 06:28:37 +02:00
|
|
|
|
2017-11-05 22:38:17 +01:00
|
|
|
$this->poll = Loop::onReadable($this->handle->socket, static function ($watcher) use (&$deferred, &$listeners, &$handle) {
|
2017-11-05 18:28:32 +01:00
|
|
|
if ($handle->poll() === pq\Connection::POLLING_FAILED) {
|
2017-11-05 22:38:17 +01:00
|
|
|
$handle = null; // Marks connection as dead.
|
2017-11-05 18:28:32 +01:00
|
|
|
Loop::disable($watcher);
|
2017-11-05 22:38:17 +01:00
|
|
|
|
|
|
|
$exception = new ConnectionException($handle->errorMessage);
|
|
|
|
|
|
|
|
foreach ($listeners as $listener) {
|
|
|
|
$listener->fail($exception);
|
|
|
|
}
|
|
|
|
|
|
|
|
if ($deferred !== null) {
|
|
|
|
$deferred->fail($exception);
|
|
|
|
}
|
|
|
|
|
2017-11-05 18:28:32 +01:00
|
|
|
return;
|
|
|
|
}
|
2017-05-16 06:28:37 +02:00
|
|
|
|
2016-09-21 07:18:24 +02:00
|
|
|
if ($deferred === null) {
|
|
|
|
return; // No active query, only notification listeners.
|
|
|
|
}
|
2017-05-16 06:28:37 +02:00
|
|
|
|
2017-11-05 18:28:32 +01:00
|
|
|
if ($handle->busy) {
|
|
|
|
return; // Not finished receiving data, poll again.
|
2016-09-14 16:27:39 +02:00
|
|
|
}
|
|
|
|
|
2017-11-05 18:28:32 +01:00
|
|
|
$deferred->resolve($handle->getResult());
|
|
|
|
|
|
|
|
if (!$deferred && empty($listeners)) {
|
2017-05-26 20:14:04 +02:00
|
|
|
Loop::disable($watcher);
|
2016-09-14 16:27:39 +02:00
|
|
|
}
|
|
|
|
});
|
|
|
|
|
|
|
|
$this->await = Loop::onWritable($this->handle->socket, static function ($watcher) use (&$deferred, $handle) {
|
|
|
|
if (!$handle->flush()) {
|
2017-05-26 20:14:04 +02:00
|
|
|
return; // Not finished sending data, continue polling for writability.
|
2016-09-14 16:27:39 +02:00
|
|
|
}
|
2017-05-16 06:28:37 +02:00
|
|
|
|
2016-09-14 16:27:39 +02:00
|
|
|
Loop::disable($watcher);
|
|
|
|
});
|
2017-05-16 06:28:37 +02:00
|
|
|
|
2016-09-14 16:27:39 +02:00
|
|
|
Loop::disable($this->poll);
|
|
|
|
Loop::disable($this->await);
|
|
|
|
|
2017-07-27 07:32:34 +02:00
|
|
|
$this->send = coroutine($this->callableFromInstanceMethod("send"));
|
2017-05-16 06:14:02 +02:00
|
|
|
$this->fetch = coroutine($this->callableFromInstanceMethod("fetch"));
|
2016-09-19 18:12:32 +02:00
|
|
|
$this->unlisten = $this->callableFromInstanceMethod("unlisten");
|
2016-09-14 16:27:39 +02:00
|
|
|
$this->release = $this->callableFromInstanceMethod("release");
|
2017-07-28 06:20:16 +02:00
|
|
|
$this->deallocate = $this->callableFromInstanceMethod("deallocate");
|
2016-09-14 16:27:39 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Frees Io watchers from loop.
|
|
|
|
*/
|
|
|
|
public function __destruct() {
|
|
|
|
Loop::cancel($this->poll);
|
|
|
|
Loop::cancel($this->await);
|
|
|
|
}
|
|
|
|
|
2017-11-05 22:38:17 +01:00
|
|
|
/**
|
|
|
|
* {@inheritdoc}
|
|
|
|
*/
|
|
|
|
public function isAlive(): bool {
|
|
|
|
return $this->handle !== null;
|
|
|
|
}
|
|
|
|
|
2016-09-14 16:27:39 +02:00
|
|
|
/**
|
|
|
|
* @param callable $method Method to execute.
|
|
|
|
* @param mixed ...$args Arguments to pass to function.
|
|
|
|
*
|
|
|
|
* @return \Generator
|
|
|
|
*
|
2017-11-05 22:43:40 +01:00
|
|
|
* @resolve \Amp\Postgres\CommandResult|\Amp\Postgres\TupleResult|\pq\Statement
|
2016-09-14 16:27:39 +02:00
|
|
|
*
|
|
|
|
* @throws \Amp\Postgres\FailureException
|
|
|
|
*/
|
|
|
|
private function send(callable $method, ...$args): \Generator {
|
2017-07-27 07:32:34 +02:00
|
|
|
while ($this->busy) {
|
|
|
|
try {
|
|
|
|
yield $this->busy->promise();
|
|
|
|
} catch (\Throwable $exception) {
|
|
|
|
// Ignore failure from another operation.
|
|
|
|
}
|
2016-09-14 16:27:39 +02:00
|
|
|
}
|
2017-05-16 06:28:37 +02:00
|
|
|
|
2017-11-05 22:38:17 +01:00
|
|
|
if (!$this->handle) {
|
|
|
|
throw new ConnectionException("The connection to the database has been lost");
|
|
|
|
}
|
|
|
|
|
2016-09-14 16:27:39 +02:00
|
|
|
try {
|
2017-05-26 20:14:04 +02:00
|
|
|
$handle = $method(...$args);
|
2017-05-16 06:28:37 +02:00
|
|
|
|
2017-07-27 07:32:34 +02:00
|
|
|
$this->deferred = $this->busy = new Deferred;
|
2017-05-16 06:28:37 +02:00
|
|
|
|
2016-09-14 16:27:39 +02:00
|
|
|
Loop::enable($this->poll);
|
|
|
|
if (!$this->handle->flush()) {
|
|
|
|
Loop::enable($this->await);
|
|
|
|
}
|
2017-05-16 06:28:37 +02:00
|
|
|
|
2016-09-14 16:27:39 +02:00
|
|
|
try {
|
2016-11-15 18:06:21 +01:00
|
|
|
$result = yield $this->deferred->promise();
|
2016-09-14 16:27:39 +02:00
|
|
|
} finally {
|
2016-09-21 07:18:24 +02:00
|
|
|
$this->deferred = null;
|
2016-09-14 16:27:39 +02:00
|
|
|
}
|
2017-05-16 06:28:37 +02:00
|
|
|
|
2016-09-14 16:27:39 +02:00
|
|
|
if (!$result instanceof pq\Result) {
|
|
|
|
throw new FailureException("Unknown query result");
|
|
|
|
}
|
2017-05-26 20:14:04 +02:00
|
|
|
} catch (pq\Exception $exception) {
|
|
|
|
throw new FailureException($this->handle->errorMessage, 0, $exception);
|
2016-09-14 16:27:39 +02:00
|
|
|
} finally {
|
2017-07-27 07:32:34 +02:00
|
|
|
$this->busy = null;
|
2016-09-14 16:27:39 +02:00
|
|
|
}
|
2017-05-16 06:28:37 +02:00
|
|
|
|
2016-09-14 16:27:39 +02:00
|
|
|
switch ($result->status) {
|
|
|
|
case pq\Result::EMPTY_QUERY:
|
|
|
|
throw new QueryError("Empty query string");
|
2017-05-16 06:28:37 +02:00
|
|
|
|
2016-09-14 16:27:39 +02:00
|
|
|
case pq\Result::COMMAND_OK:
|
2017-07-28 06:20:16 +02:00
|
|
|
if ($handle instanceof pq\Statement) {
|
|
|
|
return $handle; // Will be wrapped into a PqStatement object.
|
|
|
|
}
|
|
|
|
|
2016-09-14 16:27:39 +02:00
|
|
|
return new PqCommandResult($result);
|
2017-05-16 06:28:37 +02:00
|
|
|
|
2016-09-14 16:27:39 +02:00
|
|
|
case pq\Result::TUPLES_OK:
|
|
|
|
return new PqBufferedResult($result);
|
2017-05-16 06:28:37 +02:00
|
|
|
|
2017-02-16 23:25:52 +01:00
|
|
|
case pq\Result::SINGLE_TUPLE:
|
2017-07-27 07:32:34 +02:00
|
|
|
$this->busy = new Deferred;
|
2016-09-14 16:27:39 +02:00
|
|
|
$result = new PqUnbufferedResult($this->fetch, $result);
|
2017-11-18 05:00:52 +01:00
|
|
|
$result->onDestruct($this->release);
|
2016-09-14 16:27:39 +02:00
|
|
|
return $result;
|
2017-05-16 06:28:37 +02:00
|
|
|
|
2016-09-14 16:27:39 +02:00
|
|
|
case pq\Result::NONFATAL_ERROR:
|
|
|
|
case pq\Result::FATAL_ERROR:
|
|
|
|
throw new QueryError($result->errorMessage);
|
2017-05-16 06:28:37 +02:00
|
|
|
|
2016-09-14 16:27:39 +02:00
|
|
|
case pq\Result::BAD_RESPONSE:
|
|
|
|
throw new FailureException($result->errorMessage);
|
2017-05-16 06:28:37 +02:00
|
|
|
|
2016-09-14 16:27:39 +02:00
|
|
|
default:
|
|
|
|
throw new FailureException("Unknown result status");
|
|
|
|
}
|
|
|
|
}
|
2017-05-16 06:28:37 +02:00
|
|
|
|
2016-09-14 16:27:39 +02:00
|
|
|
private function fetch(): \Generator {
|
|
|
|
if (!$this->handle->busy) { // Results buffered.
|
|
|
|
$result = $this->handle->getResult();
|
|
|
|
} else {
|
2016-09-21 07:18:24 +02:00
|
|
|
$this->deferred = new Deferred;
|
2017-05-16 06:28:37 +02:00
|
|
|
|
2016-09-14 16:27:39 +02:00
|
|
|
Loop::enable($this->poll);
|
2017-08-01 07:38:12 +02:00
|
|
|
if (!$this->handle->flush()) {
|
|
|
|
Loop::enable($this->await);
|
|
|
|
}
|
2017-05-16 06:28:37 +02:00
|
|
|
|
2016-09-14 16:27:39 +02:00
|
|
|
try {
|
2016-11-15 18:06:21 +01:00
|
|
|
$result = yield $this->deferred->promise();
|
2016-09-14 16:27:39 +02:00
|
|
|
} finally {
|
2016-09-21 07:18:24 +02:00
|
|
|
$this->deferred = null;
|
2016-09-14 16:27:39 +02:00
|
|
|
}
|
|
|
|
}
|
2017-05-16 06:28:37 +02:00
|
|
|
|
2017-11-06 01:50:52 +01:00
|
|
|
if (!$result) {
|
|
|
|
return null; // Connection closing, end result set.
|
|
|
|
}
|
|
|
|
|
2016-09-14 16:27:39 +02:00
|
|
|
switch ($result->status) {
|
2016-09-19 18:12:32 +02:00
|
|
|
case pq\Result::TUPLES_OK: // End of result set.
|
2016-09-14 16:27:39 +02:00
|
|
|
return null;
|
2017-05-16 06:28:37 +02:00
|
|
|
|
2016-09-14 16:27:39 +02:00
|
|
|
case pq\Result::SINGLE_TUPLE:
|
|
|
|
return $result;
|
2017-05-16 06:28:37 +02:00
|
|
|
|
2016-09-14 16:27:39 +02:00
|
|
|
default:
|
|
|
|
throw new FailureException($result->errorMessage);
|
|
|
|
}
|
|
|
|
}
|
2017-05-16 06:28:37 +02:00
|
|
|
|
2016-09-14 16:27:39 +02:00
|
|
|
private function release() {
|
2017-07-29 00:34:43 +02:00
|
|
|
\assert(
|
|
|
|
$this->busy instanceof Deferred && $this->busy !== $this->deferred,
|
|
|
|
"Connection in invalid state when releasing"
|
|
|
|
);
|
|
|
|
|
2017-07-27 07:32:34 +02:00
|
|
|
$deferred = $this->busy;
|
|
|
|
$this->busy = null;
|
|
|
|
$deferred->resolve();
|
2016-09-14 16:27:39 +02:00
|
|
|
}
|
2017-05-16 06:28:37 +02:00
|
|
|
|
2017-07-28 06:20:16 +02:00
|
|
|
private function deallocate(string $name) {
|
2017-11-05 22:38:17 +01:00
|
|
|
if (!$this->handle) {
|
|
|
|
return; // Connection dead.
|
|
|
|
}
|
|
|
|
|
2017-07-28 06:20:16 +02:00
|
|
|
\assert(isset($this->statements[$name]), "Named statement not found when deallocating");
|
|
|
|
|
|
|
|
$storage = $this->statements[$name];
|
|
|
|
|
|
|
|
if (--$storage->count) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
unset($this->statements[$name]);
|
|
|
|
|
|
|
|
Promise\rethrow(new Coroutine($this->send([$storage->statement, "deallocateAsync"])));
|
|
|
|
}
|
|
|
|
|
2016-09-14 16:27:39 +02:00
|
|
|
/**
|
|
|
|
* {@inheritdoc}
|
|
|
|
*/
|
2016-11-15 18:06:21 +01:00
|
|
|
public function query(string $sql): Promise {
|
2016-09-14 16:27:39 +02:00
|
|
|
return new Coroutine($this->send([$this->handle, "execAsync"], $sql));
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* {@inheritdoc}
|
|
|
|
*/
|
2017-11-18 04:33:49 +01:00
|
|
|
public function execute(string $sql, array $params = []): Promise {
|
2017-07-26 20:49:40 +02:00
|
|
|
return new Coroutine($this->send([$this->handle, "execParamsAsync"], $sql, $params));
|
2016-09-14 16:27:39 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* {@inheritdoc}
|
|
|
|
*/
|
2016-11-15 18:06:21 +01:00
|
|
|
public function prepare(string $sql): Promise {
|
2017-07-28 06:20:16 +02:00
|
|
|
$name = self::STATEMENT_NAME_PREFIX . \sha1($sql);
|
|
|
|
|
|
|
|
if (isset($this->statements[$name])) {
|
|
|
|
$storage = $this->statements[$name];
|
|
|
|
++$storage->count;
|
|
|
|
|
|
|
|
if ($storage->promise) {
|
|
|
|
return $storage->promise;
|
|
|
|
}
|
|
|
|
|
2017-07-29 00:34:43 +02:00
|
|
|
return new Success(new PqStatement($storage->statement, $this->send, $this->deallocate));
|
2017-07-28 06:20:16 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
$this->statements[$name] = $storage = new Internal\PqStatementStorage;
|
|
|
|
|
2017-08-01 07:38:12 +02:00
|
|
|
$promise = $storage->promise = call(function () use ($storage, $name, $sql) {
|
2017-07-28 06:20:16 +02:00
|
|
|
$statement = yield from $this->send([$this->handle, "prepareAsync"], $name, $sql);
|
|
|
|
$storage->statement = $statement;
|
2017-07-29 00:34:43 +02:00
|
|
|
return new PqStatement($statement, $this->send, $this->deallocate);
|
2017-07-28 06:20:16 +02:00
|
|
|
});
|
2017-08-01 07:38:12 +02:00
|
|
|
$promise->onResolve(function ($exception) use ($storage, $name) {
|
2017-07-31 07:52:56 +02:00
|
|
|
if ($exception) {
|
|
|
|
unset($this->statements[$name]);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2017-07-28 06:20:16 +02:00
|
|
|
$storage->promise = null;
|
|
|
|
});
|
2017-08-01 07:38:12 +02:00
|
|
|
return $promise;
|
2016-09-14 16:27:39 +02:00
|
|
|
}
|
2017-05-16 06:28:37 +02:00
|
|
|
|
2016-09-21 07:18:24 +02:00
|
|
|
/**
|
|
|
|
* {@inheritdoc}
|
|
|
|
*/
|
2016-11-15 18:06:21 +01:00
|
|
|
public function notify(string $channel, string $payload = ""): Promise {
|
2016-09-21 07:18:24 +02:00
|
|
|
return new Coroutine($this->send([$this->handle, "notifyAsync"], $channel, $payload));
|
|
|
|
}
|
2017-05-16 06:28:37 +02:00
|
|
|
|
2016-09-19 18:12:32 +02:00
|
|
|
/**
|
|
|
|
* {@inheritdoc}
|
|
|
|
*/
|
2016-11-15 18:06:21 +01:00
|
|
|
public function listen(string $channel): Promise {
|
2017-05-16 06:14:02 +02:00
|
|
|
return call(function () use ($channel) {
|
2017-06-13 07:34:20 +02:00
|
|
|
if (isset($this->listeners[$channel])) {
|
|
|
|
throw new QueryError(\sprintf("Already listening on channel '%s'", $channel));
|
|
|
|
}
|
|
|
|
|
|
|
|
$this->listeners[$channel] = $emitter = new Emitter;
|
|
|
|
|
|
|
|
try {
|
|
|
|
yield from $this->send(
|
|
|
|
[$this->handle, "listenAsync"],
|
|
|
|
$channel,
|
|
|
|
static function (string $channel, string $message, int $pid) use ($emitter) {
|
|
|
|
$notification = new Notification;
|
|
|
|
$notification->channel = $channel;
|
|
|
|
$notification->pid = $pid;
|
|
|
|
$notification->payload = $message;
|
|
|
|
$emitter->emit($notification);
|
2017-07-27 07:32:34 +02:00
|
|
|
}
|
|
|
|
);
|
2017-06-13 07:34:20 +02:00
|
|
|
} catch (\Throwable $exception) {
|
|
|
|
unset($this->listeners[$channel]);
|
|
|
|
throw $exception;
|
|
|
|
}
|
|
|
|
|
2016-09-21 07:18:24 +02:00
|
|
|
Loop::enable($this->poll);
|
2017-05-16 06:14:02 +02:00
|
|
|
return new Listener($emitter->iterate(), $channel, $this->unlisten);
|
2016-09-19 18:12:32 +02:00
|
|
|
});
|
|
|
|
}
|
2017-05-16 06:28:37 +02:00
|
|
|
|
2016-09-19 18:12:32 +02:00
|
|
|
/**
|
|
|
|
* @param string $channel
|
|
|
|
*
|
2017-03-17 16:17:24 +01:00
|
|
|
* @return \Amp\Promise
|
2016-09-19 18:12:32 +02:00
|
|
|
*
|
|
|
|
* @throws \Error
|
|
|
|
*/
|
2016-11-15 18:06:21 +01:00
|
|
|
private function unlisten(string $channel): Promise {
|
2017-07-28 06:20:16 +02:00
|
|
|
\assert(isset($this->listeners[$channel]), "Not listening on that channel");
|
2017-05-16 06:28:37 +02:00
|
|
|
|
2017-01-18 19:29:48 +01:00
|
|
|
$emitter = $this->listeners[$channel];
|
2016-09-19 18:12:32 +02:00
|
|
|
unset($this->listeners[$channel]);
|
2017-05-16 06:28:37 +02:00
|
|
|
|
2017-11-06 05:36:22 +01:00
|
|
|
if (!$this->handle) {
|
|
|
|
$promise = new Success; // Connection already closed.
|
|
|
|
} else {
|
|
|
|
$promise = new Coroutine($this->send([$this->handle, "unlistenAsync"], $channel));
|
2016-09-21 07:18:24 +02:00
|
|
|
}
|
2017-05-16 06:28:37 +02:00
|
|
|
|
2017-06-21 06:04:54 +02:00
|
|
|
$promise->onResolve([$emitter, "complete"]);
|
2016-11-15 18:06:21 +01:00
|
|
|
return $promise;
|
2016-09-19 18:12:32 +02:00
|
|
|
}
|
2017-08-01 07:38:12 +02:00
|
|
|
|
|
|
|
/**
|
|
|
|
* {@inheritdoc}
|
|
|
|
*/
|
|
|
|
public function quoteString(string $data): string {
|
2017-11-06 05:36:22 +01:00
|
|
|
if (!$this->handle) {
|
|
|
|
throw new ConnectionException("The connection to the database has been lost");
|
|
|
|
}
|
|
|
|
|
2017-08-01 07:38:12 +02:00
|
|
|
return $this->handle->quote($data);
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* {@inheritdoc}
|
|
|
|
*/
|
|
|
|
public function quoteName(string $name): string {
|
2017-11-06 05:36:22 +01:00
|
|
|
if (!$this->handle) {
|
|
|
|
throw new ConnectionException("The connection to the database has been lost");
|
|
|
|
}
|
|
|
|
|
2017-08-01 07:38:12 +02:00
|
|
|
return $this->handle->quoteName($name);
|
|
|
|
}
|
2016-09-14 16:27:39 +02:00
|
|
|
}
|