classConnectionExecution
final class ConnectionExecution
Coordinates native connection execution with its shadow session.
Methods§
public function __construct(
private PDO $pdo,
?ZtdConfig $config = null,
?SessionFactory $factory = null,
)Create a shadow session for the supplied native connection.
Parameters
$pdo | PDO | |
$config | ?ZtdConfig | |
$factory | ?SessionFactory |
Calls 4
- method-call DriverSessionFactory::forConnection() line 32
- new DriverSessionFactory line 32
- new PdoConnection line 33
- static-call ZtdConfig::default() line 33
public function native(): PDOReturn the wrapped native connection.
Returns
PDOTest cases 1
Called from 6
- method-call ZtdQuery\Adapter\Pdo\ZtdPdo::inTransaction() packages/ztd-query-pdo-adapter/src/ZtdPdo.php:321
- method-call ZtdQuery\Adapter\Pdo\ZtdPdo::errorCode() packages/ztd-query-pdo-adapter/src/ZtdPdo.php:352
- method-call ZtdQuery\Adapter\Pdo\ZtdPdo::errorInfo() packages/ztd-query-pdo-adapter/src/ZtdPdo.php:370
- method-call ZtdQuery\Adapter\Pdo\ZtdPdo::getAttribute() packages/ztd-query-pdo-adapter/src/ZtdPdo.php:383
- method-call ZtdQuery\Adapter\Pdo\ZtdPdo::setAttribute() packages/ztd-query-pdo-adapter/src/ZtdPdo.php:397
- method-call ZtdQuery\Adapter\Pdo\ZtdPdo::quote() packages/ztd-query-pdo-adapter/src/ZtdPdo.php:410
public function session(): SessionReturn the shadow session shared by all statements on this connection.
Returns
Test cases 4
ConnectionExecutionTest::testCommitKeepsShadowWritesAcrossTheNextRollbackcallsConnectionExecutionTest::testLastInsertIdChoosesShadowOrNativeStatecallsConnectionExecutionTest::testRollBackRemovesUncommittedShadowWritescallsConnectionExecutionTest::testSessionKeepsShadowWritesOffTheNativeConnectioncalls
Called from 3
- method-call ZtdQuery\Adapter\Pdo\ZtdPdo::enableZtd() packages/ztd-query-pdo-adapter/src/ZtdPdo.php:110
- method-call ZtdQuery\Adapter\Pdo\ZtdPdo::disableZtd() packages/ztd-query-pdo-adapter/src/ZtdPdo.php:129
- method-call ZtdQuery\Adapter\Pdo\ZtdPdo::isZtdEnabled() packages/ztd-query-pdo-adapter/src/ZtdPdo.php:143
public function prepare<TOption>(
string $query,
array<TOption> $options,
Closure(PDOStatement, Session, RewritePlan, PreparedQuery, int): PDOStatement $wrap,
): PDOStatement|falsePrepare native SQL and let the facade wrap the resulting execution plan.
Parameters
$query | string | |
$options | array<TOption> | Opaque options forwarded to the native driver. |
$wrap | Closure(PDOStatement, Session, RewritePlan, PreparedQuery, int): PDOStatement |
Returns
PDOStatement|falseThrows
ZtdPdoException When rewriting cannot prepare the statement.Test cases 1
Called from 1
Calls 11
- method-call Session::isEnabled() line 62
- method-call
PDO::prepare()line 63 - new PreparedQuery line 68
- method-call PreparedQuery::rewrite() line 69
- method-call Session::parameterBindingCompiler() line 70
- method-call PreparedQuery::prepare() line 71
- new ZtdPdoException line 73
- method-call
PDO::getAttribute()line 76 - class-const
PDO::ATTR_DEFAULT_FETCH_MODE()line 76 - function-call
is_intline 83 - class-const
PDO::FETCH_BOTH()line 83
public function query<TFetchArgument>(
string $query,
?int $fetchMode,
array<TFetchArgument> $fetchModeArgs,
Closure(string): PDOStatement|false $prepare,
): PDOStatement|falseExecute a query through the facade's preparation dispatch.
Parameters
$query | string | |
$fetchMode | ?int | |
$fetchModeArgs | array<TFetchArgument> | Native fetch options. |
$prepare | Closure(string): PDOStatement|false |
Returns
PDOStatement|falseCalled from 1
Calls 4
- method-call Session::isEnabled() line 96
- method-call Session::transactionStatement() line 97
- method-call
PDO::query()line 99 - method-call Session::applyTransactionStatement() line 101
public function exec(string $statement, Closure(string): int|false $execute): int|falseExecute statements and synchronize native transaction and shadow state.
Parameters
$statement | string | |
$execute | Closure(string): int|false | Preserve facade dispatch for each batch statement. |
Returns
int|falseThrows
ZtdPdoException When shadow execution rejects the SQL.Test cases 2
Called from 1
Calls 8
- method-call Session::isEnabled() line 132
- method-call
PDO::exec()line 133 - method-call Session::splitStatements() line 136
- function-call
countline 137 - method-call Session::transactionStatement() line 150
- method-call Session::applyTransactionStatement() line 154
- method-call Session::execStatement() line 161
- new ZtdPdoException line 163
public function beginTransaction(): boolBegin the native transaction before opening a shadow transaction.
Returns
boolTest cases 4
ConnectionExecutionTest::testBeginTransactionPropagatesNativeFailurecallsConnectionExecutionTest::testCommitKeepsShadowWritesAcrossTheNextRollbackcallsConnectionExecutionTest::testNativeTransactionStatementsKeepTheSessionSynchronizedcallsConnectionExecutionTest::testRollBackRemovesUncommittedShadowWritescalls
Called from 1
Calls 2
- method-call
PDO::beginTransaction()line 172 - method-call Session::beginTransaction() line 174
public function commit(): boolCommit the shadow transaction after the native commit succeeds.
Returns
boolTest cases 2
Called from 1
Calls 2
- method-call
PDO::commit()line 185 - method-call Session::commitTransaction() line 187
public function rollBack(): boolRoll back shadow state after the native rollback succeeds.
Returns
boolTest cases 2
Called from 1
Calls 2
- method-call
PDO::rollBack()line 198 - method-call Session::rollBackTransaction() line 200
public function lastInsertId(?string $name = null): string|falsePrefer the shadow-generated key when ZTD handles an unnamed sequence.
Parameters
$name | ?string |
Returns
string|falseTest cases 1
Called from 1
Calls 3
- method-call Session::isEnabled() line 211
- method-call Session::lastInsertId() line 212
- method-call
PDO::lastInsertId()line 218
Private surface 2§
Implementation details, listed for orientation only.
private Session $sessionprivate PDO $pdoTest cases 18§
Test cases that cover or call this symbol, from the coverage report and from the analyzed test sources.
Dedicated tests 9
ConnectionExecutionTest::testBeginTransactionPropagatesNativeFailurecallsConnectionExecutionTest::testCommitKeepsShadowWritesAcrossTheNextRollbackcallsConnectionExecutionTest::testExecBatchStopsWhenTheDispatchedNativeStatementFailscallsConnectionExecutionTest::testLastInsertIdChoosesShadowOrNativeStatecallsConnectionExecutionTest::testNativeTransactionStatementsKeepTheSessionSynchronizedcallsConnectionExecutionTest::testPreparePreservesOpaqueNativeDriverOptionscallsConnectionExecutionTest::testQueryPreservesPreparationDispatchAndFetchArgumentscallsConnectionExecutionTest::testRollBackRemovesUncommittedShadowWritescallsConnectionExecutionTest::testSessionKeepsShadowWritesOffTheNativeConnectioncalls
Other tests reaching this symbol 9
PdoConnectionTestcallsPdoStatementTestcallsDriverSessionFactoryTestcallsParameterBinderTestcallsPreparedQueryTestcallsStatementExecutionTestcallsZtdPdoExceptionTestcallsZtdPdoStatementTestcallsZtdPdoTestcalls
Relations§
Instantiated in 2
Method calls 16
- method-call ZtdQuery\Adapter\Pdo\ZtdPdo::enableZtd() packages/ztd-query-pdo-adapter/src/ZtdPdo.php:110
- method-call ZtdQuery\Adapter\Pdo\ZtdPdo::disableZtd() packages/ztd-query-pdo-adapter/src/ZtdPdo.php:129
- method-call ZtdQuery\Adapter\Pdo\ZtdPdo::isZtdEnabled() packages/ztd-query-pdo-adapter/src/ZtdPdo.php:143
- method-call ZtdQuery\Adapter\Pdo\ZtdPdo::prepare() packages/ztd-query-pdo-adapter/src/ZtdPdo.php:168
- method-call ZtdQuery\Adapter\Pdo\ZtdPdo::query() packages/ztd-query-pdo-adapter/src/ZtdPdo.php:196
- method-call ZtdQuery\Adapter\Pdo\ZtdPdo::exec() packages/ztd-query-pdo-adapter/src/ZtdPdo.php:221
- method-call ZtdQuery\Adapter\Pdo\ZtdPdo::beginTransaction() packages/ztd-query-pdo-adapter/src/ZtdPdo.php:268
- method-call ZtdQuery\Adapter\Pdo\ZtdPdo::commit() packages/ztd-query-pdo-adapter/src/ZtdPdo.php:287
- method-call ZtdQuery\Adapter\Pdo\ZtdPdo::rollBack() packages/ztd-query-pdo-adapter/src/ZtdPdo.php:305
- method-call ZtdQuery\Adapter\Pdo\ZtdPdo::inTransaction() packages/ztd-query-pdo-adapter/src/ZtdPdo.php:321
- method-call ZtdQuery\Adapter\Pdo\ZtdPdo::lastInsertId() packages/ztd-query-pdo-adapter/src/ZtdPdo.php:337
- method-call ZtdQuery\Adapter\Pdo\ZtdPdo::errorCode() packages/ztd-query-pdo-adapter/src/ZtdPdo.php:352
- method-call ZtdQuery\Adapter\Pdo\ZtdPdo::errorInfo() packages/ztd-query-pdo-adapter/src/ZtdPdo.php:370
- method-call ZtdQuery\Adapter\Pdo\ZtdPdo::getAttribute() packages/ztd-query-pdo-adapter/src/ZtdPdo.php:383
- method-call ZtdQuery\Adapter\Pdo\ZtdPdo::setAttribute() packages/ztd-query-pdo-adapter/src/ZtdPdo.php:397
- method-call ZtdQuery\Adapter\Pdo\ZtdPdo::quote() packages/ztd-query-pdo-adapter/src/ZtdPdo.php:410