@@ -72,7 +72,7 @@ class Connection implements ConnectionInterface
7272 /**
7373 * Instance of the db-driver defined in the configs.
7474 */
75- protected ? DriverInterface $ dbDriver = null ;
75+ protected DriverInterface $ dbDriver ;
7676
7777 /**
7878 * The number of transactions currently opened.
@@ -120,7 +120,7 @@ public function close(): void
120120 $ this ->logger ?->warning('Rolled back open transactions on deletion of current instance of Db! ' );
121121 }
122122
123- if ($ this ->dbDriver !== null && $ this -> connected ) {
123+ if ($ this ->connected ) {
124124 $ this ->logger ?->info('closing database-connection ' );
125125
126126 $ this ->dbDriver ->dbclose ();
@@ -216,7 +216,7 @@ public function selectRow(
216216 ),
217217 );
218218
219- $ row = $ this ->getPRow ($ query , array_values ($ identifiers ), 0 , $ cached , $ escapes );
219+ $ row = $ this ->getPRow ($ query , array_values ($ identifiers ), 0 , $ cached , $ escapes ?? [] );
220220 if ($ row === []) {
221221 return null ;
222222 }
@@ -317,17 +317,15 @@ public function _pQuery(string $query, array $params = [], array $escapes = []):
317317 // Increasing the counter
318318 $ this ->number ++;
319319
320- if ($ this ->dbDriver !== null ) {
321- try {
322- $ output = $ this ->dbDriver ->_pQuery ($ query , $ this ->dbsafeParams ($ params , $ escapes ));
323- } catch (QueryException $ e ) {
324- $ prettifiedQuery = $ this ->prettifyQuery ($ e ->getQuery (), $ e ->getParams ());
320+ try {
321+ $ output = $ this ->dbDriver ->_pQuery ($ query , $ this ->dbsafeParams ($ params , $ escapes ));
322+ } catch (QueryException $ e ) {
323+ $ prettifiedQuery = $ this ->prettifyQuery ($ e ->getQuery (), $ e ->getParams ());
325324
326- $ this ->logger ->error ($ e ->getMessage ());
327- $ this ->logger ->error ('Query: ' . $ prettifiedQuery );
325+ $ this ->logger ? ->error($ e ->getMessage ());
326+ $ this ->logger ? ->error('Query: ' . $ prettifiedQuery );
328327
329- throw $ e ;
330- }
328+ throw $ e ;
331329 }
332330
333331 if (!$ output ) {
@@ -618,10 +616,7 @@ private function getError(string $query, array $params): void
618616 $ this ->dbconnect ();
619617 }
620618
621- $ error = '' ;
622- if ($ this ->dbDriver !== null ) {
623- $ error = $ this ->dbDriver ->getError ();
624- }
619+ $ error = $ this ->dbDriver ->getError ();
625620
626621 // reprocess query
627622 $ query = str_ireplace (
@@ -665,10 +660,6 @@ public function beginTransaction(): void
665660 $ this ->dbconnect ();
666661 }
667662
668- if ($ this ->dbDriver === null ) {
669- return ;
670- }
671-
672663 // just start a new transaction, if no other transaction is open.
673664 if ($ this ->numberOfOpenTransactions === 0 ) {
674665 $ this ->dbDriver ->beginTransaction ();
@@ -700,10 +691,6 @@ public function commit(): void
700691 $ this ->dbconnect ();
701692 }
702693
703- if ($ this ->dbDriver === null ) {
704- return ;
705- }
706-
707694 // check, if the current tx is allowed to be committed.
708695 if ($ this ->numberOfOpenTransactions === 1 ) {
709696 $ this ->numberOfOpenTransactions --;
@@ -743,10 +730,6 @@ public function rollBack(): void
743730 $ this ->dbconnect ();
744731 }
745732
746- if ($ this ->dbDriver === null ) {
747- return ;
748- }
749-
750733 if ($ this ->numberOfOpenTransactions === 1 ) {
751734 $ this ->dbDriver ->rollBack ();
752735 $ this ->currentTransactionIsDirty = false ;
@@ -802,15 +785,13 @@ public function getTables(?string $prefix = null): array
802785
803786 $ this ->tablesCache [$ prefix ] = [];
804787
805- if ($ this ->dbDriver !== null ) {
806- // increase global counter
807- $ this ->number ++;
808- $ tables = $ this ->dbDriver ->getTables ();
788+ // increase global counter
789+ $ this ->number ++;
790+ $ tables = $ this ->dbDriver ->getTables ();
809791
810- foreach ($ tables as $ table ) {
811- if (str_starts_with ((string ) $ table ['name ' ], $ prefix )) {
812- $ this ->tablesCache [$ prefix ][] = $ table ['name ' ];
813- }
792+ foreach ($ tables as $ table ) {
793+ if (str_starts_with ((string ) $ table ['name ' ], $ prefix )) {
794+ $ this ->tablesCache [$ prefix ][] = $ table ['name ' ];
814795 }
815796 }
816797
@@ -845,7 +826,7 @@ public function getColumnsOfTable(string $tableName): array
845826 $ columnName = $ column ->getName ();
846827 $ return [$ columnName ] = [
847828 'columnName ' => $ columnName ,
848- 'columnType ' => $ column ->getInternalType (),
829+ 'columnType ' => $ column ->getInternalType () ?? DataType:: CHAR254 ,
849830 ];
850831 }
851832
@@ -949,7 +930,7 @@ public function generateTableFromMetadata(Table $table): void
949930 {
950931 $ columns = [];
951932 foreach ($ table ->getColumns () as $ colDef ) {
952- $ columns [$ colDef ->getName ()] = [$ colDef ->getInternalType (), $ colDef ->isNullable ()];
933+ $ columns [$ colDef ->getName ()] = [$ colDef ->getInternalType () ?? DataType:: CHAR254 , $ colDef ->isNullable ()];
953934 }
954935
955936 $ primary = [];
@@ -1195,10 +1176,6 @@ public function getDbInfo(): array
11951176 $ this ->dbconnect ();
11961177 }
11971178
1198- if ($ this ->dbDriver === null ) {
1199- return [];
1200- }
1201-
12021179 return $ this ->dbDriver ->getDbInfo ();
12031180 }
12041181
0 commit comments