File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 22
33namespace Amp \Sql ;
44
5+ /**
6+ * @template TResult extends Result
7+ * @template TStatement extends Statement
8+ */
59interface Executor extends TransientResource
610{
711 /**
812 * @param string $sql SQL query to execute.
913 *
14+ * @return TResult
15+ *
1016 * @throws SqlException If the operation fails due to unexpected condition.
1117 * @throws ConnectionException If the connection to the database is lost.
1218 * @throws QueryError If the operation fails due to an error in the query (such as a syntax error).
@@ -16,6 +22,8 @@ public function query(string $sql): Result;
1622 /**
1723 * @param string $sql SQL query to prepare.
1824 *
25+ * @return TStatement
26+ *
1927 * @throws SqlException If the operation fails due to unexpected condition.
2028 * @throws ConnectionException If the connection to the database is lost.
2129 * @throws QueryError If the operation fails due to an error in the query (such as a syntax error).
@@ -26,9 +34,16 @@ public function prepare(string $sql): Statement;
2634 * @param string $sql SQL query to prepare and execute.
2735 * @param mixed[] $params Query parameters.
2836 *
37+ * @return TResult
38+ *
2939 * @throws SqlException If the operation fails due to unexpected condition.
3040 * @throws ConnectionException If the connection to the database is lost.
3141 * @throws QueryError If the operation fails due to an error in the query (such as a syntax error).
3242 */
3343 public function execute (string $ sql , array $ params = []): Result ;
44+
45+ /**
46+ * Closes the executor. No further queries may be performed.
47+ */
48+ public function close (): void ;
3449}
Original file line number Diff line number Diff line change 22
33namespace Amp \Sql ;
44
5+ /**
6+ * @template TResult extends Result
7+ * @template TStatement extends Statement
8+ * @template TTransaction extends Transaction
9+ *
10+ * @extends Executor<TResult, TStatement>
11+ */
512interface Link extends Executor
613{
714 /**
815 * Starts a transaction on a single connection.
916 *
10- * @param TransactionIsolation $isolation Transaction isolation level.
17+ * @param TransactionIsolation $isolation Transaction isolation level.'
18+ *
19+ * @return TTransaction
1120 */
1221 public function beginTransaction (
1322 TransactionIsolation $ isolation = TransactionIsolationLevel::Committed,
Original file line number Diff line number Diff line change 22
33namespace Amp \Sql ;
44
5+ /**
6+ * @template TResult extends Result
7+ * @template TStatement extends Statement
8+ * @template TTransaction extends Transaction
9+ *
10+ * @extends Link<TResult, TStatement, TTransaction>
11+ */
512interface Pool extends Link
613{
714 /**
815 * Gets a single connection from the pool to run a set of queries against a single connection.
916 * Generally a transaction should be used instead of this method.
17+ *
18+ * @return Link<TResult, TStatement, TTransaction>
1019 */
1120 public function extractConnection (): Link ;
1221
Original file line number Diff line number Diff line change 44
55use Amp \Cancellation ;
66
7+ /**
8+ * @template TConfig extends SqlConfig
9+ * @template TLink extends Link
10+ */
711interface SqlConnector
812{
913 /**
1014 * Returns a new database connection based on the given configuration.
1115 * Implementations may provide further parameters, such as a Cancellation.
16+ *
17+ * @param TConfig $config
18+ *
19+ * @return TLink
1220 */
1321 public function connect (SqlConfig $ config , ?Cancellation $ cancellation = null ): Link ;
1422}
Original file line number Diff line number Diff line change 22
33namespace Amp \Sql ;
44
5+ /**
6+ * @template TResult extends Result
7+ */
58interface Statement extends TransientResource
69{
710 /**
8- * @param mixed[] $params
11+ * @return TResult
912 */
1013 public function execute (array $ params = []): Result ;
1114
Original file line number Diff line number Diff line change 22
33namespace Amp \Sql ;
44
5+ /**
6+ * @template TResult extends Result
7+ * @template TStatement extends Statement
8+ * @extends Executor<TResult, TStatement>
9+ */
510interface Transaction extends Executor
611{
712 public function getIsolationLevel (): TransactionIsolation ;
You can’t perform that action at this time.
0 commit comments