Commit e7ec27c 1 parent 264407b commit e7ec27c Copy full SHA for e7ec27c
File tree 1 file changed +16
-6
lines changed
1 file changed +16
-6
lines changed Original file line number Diff line number Diff line change @@ -69,6 +69,7 @@ class Database {
69
69
*
70
70
*/
71
71
private $ tablesArr ;
72
+ private $ lastErr ;
72
73
/**
73
74
* Creates new instance of the class.
74
75
*
@@ -86,6 +87,10 @@ public function __construct(?ConnectionInfo $connectionInfo) {
86
87
}
87
88
$ this ->queries = [];
88
89
$ this ->tablesArr = [];
90
+ $ this ->lastErr = [
91
+ 'code ' => 0 ,
92
+ 'message ' => ''
93
+ ];
89
94
}
90
95
/**
91
96
* Start SQL transaction.
@@ -408,16 +413,13 @@ public function getExecutedQueries() : array {
408
413
*/
409
414
public function getLastError () : array {
410
415
if ($ this ->connection !== null ) {
411
- return [
416
+ $ this -> lastErr = [
412
417
'message ' => $ this ->connection ->getLastErrMessage (),
413
418
'code ' => $ this ->connection ->getLastErrCode ()
414
419
];
415
420
}
416
421
417
- return [
418
- 'message ' => '' ,
419
- 'code ' => 0
420
- ];
422
+ return $ this ->lastErr ;
421
423
}
422
424
/**
423
425
* Returns the last generated SQL query.
@@ -549,7 +551,15 @@ public function isConnected() : bool {
549
551
if ($ this ->getConnectionInfo () === null ) {
550
552
return false ;
551
553
}
552
- if ($ this ->getConnection () === null ) {
554
+ try {
555
+ if ($ this ->getConnection () === null ) {
556
+ return false ;
557
+ }
558
+ } catch (DatabaseException $ ex ) {
559
+ $ this ->lastErr = [
560
+ 'code ' => $ ex ->getCode (),
561
+ 'message ' => $ ex ->getMessage ()
562
+ ];
553
563
return false ;
554
564
}
555
565
You can’t perform that action at this time.
0 commit comments