@@ -59,6 +59,12 @@ public function __construct(
5959if (($ options ['newDateTime ' ] ?? null ) === false ) {
6060$ this ->rowNormalizer = fn ($ row , $ resultSet ) => Helpers::normalizeRow ($ row , $ resultSet , DateTime::class);
6161}
62+
63+ $ driver = explode (': ' , $ dsn )[0 ];
64+ $ class = empty ($ options ['driverClass ' ])
65+ ? (self ::Drivers['pdo- ' . $ driver ] ?? throw new \LogicException ("Unknown PDO driver ' $ driver'. " ))
66+ : $ options ['driverClass ' ];
67+ $ this ->driver = new $ class ;
6268}
6369
6470
@@ -77,13 +83,7 @@ public function connect(): void
7783throw ConnectionException::from ($ e );
7884}
7985
80- $ driver = explode (': ' , $ this ->dsn )[0 ];
81- $ class = empty ($ this ->options ['driverClass ' ])
82- ? (self ::Drivers['pdo- ' . $ driver ] ?? throw new \LogicException ("Unknown PDO driver ' $ driver'. " ))
83- : $ this ->options ['driverClass ' ];
84- $ this ->driver = new $ class ;
8586$ this ->engine = $ this ->driver ->createEngine ();
86- $ this ->preprocessor = new SqlPreprocessor ($ this );
8787$ this ->engine ->initialize ($ this , $ this ->options );
8888Arrays::invoke ($ this ->onConnect , $ this );
8989}
@@ -286,6 +286,7 @@ public function queryArgs(string $sql, array $params): Result
286286public function preprocess (string $ sql , ...$ params ): array
287287{
288288$ this ->connect ();
289+ $ this ->preprocessor ??= new SqlPreprocessor ($ this );
289290return $ params
290291? $ this ->preprocessor ->process (func_get_args ())
291292: [$ sql , []];
0 commit comments