Skip to content

Commit 566fea7

Browse files
committed
Add Sql prefix to all classes
1 parent 9479805 commit 566fea7

19 files changed

Lines changed: 144 additions & 144 deletions

src/Connection.php

Lines changed: 0 additions & 31 deletions
This file was deleted.

src/Executor.php

Lines changed: 0 additions & 44 deletions
This file was deleted.

src/Link.php

Lines changed: 0 additions & 20 deletions
This file was deleted.

src/SqlConnection.php

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
<?php declare(strict_types=1);
2+
3+
namespace Amp\Sql;
4+
5+
/**
6+
* @template TConfig of SqlConfig
7+
* @template TResult of SqlResult
8+
* @template TStatement of SqlStatement<TResult>
9+
* @template TTransaction of SqlTransaction
10+
*
11+
* @extends SqlLink<TResult, TStatement, TTransaction>
12+
*/
13+
interface SqlConnection extends SqlLink
14+
{
15+
/**
16+
* @return TConfig The configuration used to create this connection.
17+
*/
18+
public function getConfig(): SqlConfig;
19+
20+
/**
21+
* @return SqlTransactionIsolation Current transaction isolation used when beginning transactions on this connection.
22+
*/
23+
public function getTransactionIsolation(): SqlTransactionIsolation;
24+
25+
/**
26+
* Sets the transaction isolation level for transactions began on this link.
27+
*
28+
* @see SqlLink::beginTransaction()
29+
*/
30+
public function setTransactionIsolation(SqlTransactionIsolation $isolation): void;
31+
}
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,6 @@
22

33
namespace Amp\Sql;
44

5-
class ConnectionException extends SqlException
5+
class SqlConnectionException extends SqlException
66
{
77
}

src/Pool.php renamed to src/SqlConnectionPool.php

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -4,21 +4,21 @@
44

55
/**
66
* @template TConfig of SqlConfig
7-
* @template TResult of Result
8-
* @template TStatement of Statement<TResult>
9-
* @template TTransaction of Transaction
7+
* @template TResult of SqlResult
8+
* @template TStatement of SqlStatement<TResult>
9+
* @template TTransaction of SqlTransaction
1010
*
11-
* @extends Connection<TConfig, TResult, TStatement, TTransaction>
11+
* @extends SqlConnection<TConfig, TResult, TStatement, TTransaction>
1212
*/
13-
interface Pool extends Connection
13+
interface SqlConnectionPool extends SqlConnection
1414
{
1515
/**
1616
* Gets a single connection from the pool to run a set of queries against a single connection.
1717
* Generally a transaction should be used instead of this method.
1818
*
19-
* @return Connection<TConfig, TResult, TStatement, TTransaction>
19+
* @return SqlConnection<TConfig, TResult, TStatement, TTransaction>
2020
*/
21-
public function extractConnection(): Connection;
21+
public function extractConnection(): SqlConnection;
2222

2323
/**
2424
* @return int Total number of active connections in the pool.

src/SqlConnector.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66

77
/**
88
* @template TConfig of SqlConfig
9-
* @template TConnection of Connection
9+
* @template TConnection of SqlConnection
1010
*/
1111
interface SqlConnector
1212
{
@@ -18,7 +18,7 @@ interface SqlConnector
1818
*
1919
* @return TConnection
2020
*
21-
* @throws ConnectionException
21+
* @throws SqlConnectionException
2222
*/
23-
public function connect(SqlConfig $config, ?Cancellation $cancellation = null): Connection;
23+
public function connect(SqlConfig $config, ?Cancellation $cancellation = null): SqlConnection;
2424
}

src/SqlExecutor.php

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
<?php declare(strict_types=1);
2+
3+
namespace Amp\Sql;
4+
5+
/**
6+
* @template TResult of SqlResult
7+
* @template TStatement of SqlStatement
8+
*/
9+
interface SqlExecutor extends SqlTransientResource
10+
{
11+
/**
12+
* @param string $sql SQL query to execute.
13+
*
14+
* @return TResult
15+
*
16+
* @throws SqlException If the operation fails due to unexpected condition.
17+
* @throws SqlConnectionException If the connection to the database is lost.
18+
* @throws SqlQueryError If the operation fails due to an error in the query (such as a syntax error).
19+
*/
20+
public function query(string $sql): SqlResult;
21+
22+
/**
23+
* @param string $sql SQL query to prepare.
24+
*
25+
* @return TStatement
26+
*
27+
* @throws SqlException If the operation fails due to unexpected condition.
28+
* @throws SqlConnectionException If the connection to the database is lost.
29+
* @throws SqlQueryError If the operation fails due to an error in the query (such as a syntax error).
30+
*/
31+
public function prepare(string $sql): SqlStatement;
32+
33+
/**
34+
* @param string $sql SQL query to prepare and execute.
35+
* @param array<int, mixed>|array<string, mixed> $params Query parameters.
36+
*
37+
* @return TResult
38+
*
39+
* @throws SqlException If the operation fails due to unexpected condition.
40+
* @throws SqlConnectionException If the connection to the database is lost.
41+
* @throws SqlQueryError If the operation fails due to an error in the query (such as a syntax error).
42+
*/
43+
public function execute(string $sql, array $params = []): SqlResult;
44+
}

src/SqlLink.php

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
<?php declare(strict_types=1);
2+
3+
namespace Amp\Sql;
4+
5+
/**
6+
* @template TResult of SqlResult
7+
* @template TStatement of SqlStatement<TResult>
8+
* @template TTransaction of SqlTransaction
9+
*
10+
* @extends SqlExecutor<TResult, TStatement>
11+
*/
12+
interface SqlLink extends SqlExecutor
13+
{
14+
/**
15+
* Starts a transaction, returning an object where all queries are executed on a single connection.
16+
*
17+
* @return TTransaction
18+
*/
19+
public function beginTransaction(): SqlTransaction;
20+
}
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
namespace Amp\Sql;
44

5-
class QueryError extends \Error
5+
class SqlQueryError extends \Error
66
{
77
public function __construct(
88
string $message,

0 commit comments

Comments
 (0)