@@ -98,13 +98,6 @@ class Connection implements DriverConnection
98
98
/** @var ExpressionBuilder */
99
99
protected $ _expr ;
100
100
101
- /**
102
- * Whether or not a connection has been established.
103
- *
104
- * @var bool
105
- */
106
- private $ isConnected = false ;
107
-
108
101
/**
109
102
* The current auto-commit mode of this connection.
110
103
*
@@ -192,8 +185,7 @@ public function __construct(
192
185
$ this ->params = $ params ;
193
186
194
187
if (isset ($ params ['pdo ' ])) {
195
- $ this ->_conn = $ params ['pdo ' ];
196
- $ this ->isConnected = true ;
188
+ $ this ->_conn = $ params ['pdo ' ];
197
189
unset($ this ->params ['pdo ' ]);
198
190
}
199
191
@@ -356,16 +348,15 @@ public function getExpressionBuilder()
356
348
*/
357
349
public function connect ()
358
350
{
359
- if ($ this ->isConnected ) {
351
+ if ($ this ->_conn !== null ) {
360
352
return false ;
361
353
}
362
354
363
355
$ driverOptions = $ this ->params ['driverOptions ' ] ?? [];
364
356
$ user = $ this ->params ['user ' ] ?? null ;
365
357
$ password = $ this ->params ['password ' ] ?? null ;
366
358
367
- $ this ->_conn = $ this ->_driver ->connect ($ this ->params , $ user , $ password , $ driverOptions );
368
- $ this ->isConnected = true ;
359
+ $ this ->_conn = $ this ->_driver ->connect ($ this ->params , $ user , $ password , $ driverOptions );
369
360
370
361
$ this ->transactionNestingLevel = 0 ;
371
362
@@ -524,7 +515,7 @@ public function setAutoCommit($autoCommit)
524
515
$ this ->autoCommit = $ autoCommit ;
525
516
526
517
// Commit all currently active transactions if any when switching auto-commit mode.
527
- if ($ this ->isConnected !== true || $ this ->transactionNestingLevel === 0 ) {
518
+ if ($ this ->_conn === null || $ this ->transactionNestingLevel === 0 ) {
528
519
return ;
529
520
}
530
521
@@ -689,7 +680,7 @@ public function fetchOne(string $query, array $params = [], array $types = [])
689
680
*/
690
681
public function isConnected ()
691
682
{
692
- return $ this ->isConnected ;
683
+ return $ this ->_conn !== null ;
693
684
}
694
685
695
686
/**
@@ -771,8 +762,6 @@ public function delete($tableExpression, array $identifier, array $types = [])
771
762
public function close ()
772
763
{
773
764
$ this ->_conn = null ;
774
-
775
- $ this ->isConnected = false ;
776
765
}
777
766
778
767
/**
0 commit comments