Add prepare method to StatementPool

This commit is contained in:
Aaron Piotrowski 2018-09-26 11:32:13 -05:00
parent 9b667bafdf
commit 04fc107cc0
No known key found for this signature in database
GPG Key ID: ADD1EF783EDE9EEB
1 changed files with 11 additions and 0 deletions

View File

@ -26,6 +26,16 @@ abstract class StatementPool implements Statement
/** @var callable */
private $prepare;
/**
* Performs any necessary actions to the statement to prepare it for execution, returning the same or a new
* Statement object if necessary.
*
* @param Statement $statement
*
* @return Statement
*/
abstract protected function prepare(Statement $statement): Statement;
/**
* @param ResultSet $resultSet
* @param callable $release
@ -87,6 +97,7 @@ abstract class StatementPool implements Statement
\assert($statement instanceof Statement);
try {
$statement = $this->prepare($statement);
$result = yield $statement->execute($params);
} catch (\Throwable $exception) {
$this->push($statement);