A few renames

This commit is contained in:
Aaron Piotrowski 2022-04-11 22:21:19 -05:00
parent 25cf4d6802
commit 4f5449c828
No known key found for this signature in database
GPG Key ID: ADD1EF783EDE9EEB
7 changed files with 19 additions and 19 deletions

View File

@ -2,6 +2,6 @@
namespace Amp\Sql; namespace Amp\Sql;
class ConnectionException extends FailureException class ConnectionException extends SqlException
{ {
} }

View File

@ -7,7 +7,7 @@ interface Executor extends TransientResource
/** /**
* @param string $sql SQL query to execute. * @param string $sql SQL query to execute.
* *
* @throws FailureException If the operation fails due to unexpected condition. * @throws SqlException If the operation fails due to unexpected condition.
* @throws ConnectionException If the connection to the database is lost. * @throws ConnectionException If the connection to the database is lost.
* @throws QueryError If the operation fails due to an error in the query (such as a syntax error). * @throws QueryError If the operation fails due to an error in the query (such as a syntax error).
*/ */
@ -16,7 +16,7 @@ interface Executor extends TransientResource
/** /**
* @param string $sql SQL query to prepare. * @param string $sql SQL query to prepare.
* *
* @throws FailureException If the operation fails due to unexpected condition. * @throws SqlException If the operation fails due to unexpected condition.
* @throws ConnectionException If the connection to the database is lost. * @throws ConnectionException If the connection to the database is lost.
* @throws QueryError If the operation fails due to an error in the query (such as a syntax error). * @throws QueryError If the operation fails due to an error in the query (such as a syntax error).
*/ */
@ -26,7 +26,7 @@ interface Executor extends TransientResource
* @param string $sql SQL query to prepare and execute. * @param string $sql SQL query to prepare and execute.
* @param mixed[] $params Query parameters. * @param mixed[] $params Query parameters.
* *
* @throws FailureException If the operation fails due to unexpected condition. * @throws SqlException If the operation fails due to unexpected condition.
* @throws ConnectionException If the connection to the database is lost. * @throws ConnectionException If the connection to the database is lost.
* @throws QueryError If the operation fails due to an error in the query (such as a syntax error). * @throws QueryError If the operation fails due to an error in the query (such as a syntax error).
*/ */

View File

@ -1,7 +0,0 @@
<?php
namespace Amp\Sql;
class FailureException extends \Exception
{
}

View File

@ -4,12 +4,12 @@ namespace Amp\Sql;
class QueryError extends \Error class QueryError extends \Error
{ {
protected readonly string $query; public function __construct(
string $message,
public function __construct(string $message, string $query = "", \Throwable $previous = null) protected readonly string $query = "",
{ ?\Throwable $previous = null,
) {
parent::__construct($message, 0, $previous); parent::__construct($message, 0, $previous);
$this->query = $query;
} }
final public function getQuery(): string final public function getQuery(): string

View File

@ -2,7 +2,7 @@
namespace Amp\Sql; namespace Amp\Sql;
abstract class ConnectionConfig abstract class SqlConfig
{ {
public const KEY_MAP = [ public const KEY_MAP = [
'hostname' => 'host', 'hostname' => 'host',

View File

@ -2,11 +2,11 @@
namespace Amp\Sql; namespace Amp\Sql;
interface Connector interface SqlConnector
{ {
/** /**
* Returns a new database connection based on the given configuration. * Returns a new database connection based on the given configuration.
* Implementations may provide further parameters, such as a Cancellation. * Implementations may provide further parameters, such as a Cancellation.
*/ */
public function connect(ConnectionConfig $config): Link; public function connect(SqlConfig $config): Link;
} }

7
src/SqlException.php Normal file
View File

@ -0,0 +1,7 @@
<?php
namespace Amp\Sql;
class SqlException extends \Exception
{
}