File tree Expand file tree Collapse file tree 4 files changed +59
-1
lines changed
Expand file tree Collapse file tree 4 files changed +59
-1
lines changed Original file line number Diff line number Diff line change 1010namespace Dibi \Drivers ;
1111
1212use Dibi ;
13+ use Throwable ;
1314
1415
1516/**
@@ -246,7 +247,11 @@ public function rollback(string $savepoint = null): void
246247 */
247248 public function getResource (): ?\mysqli
248249 {
249- return @$ this ->connection ->thread_id ? $ this ->connection : null ;
250+ try {
251+ return @$ this ->connection ->thread_id ? $ this ->connection : null ;
252+ } catch (Throwable $ e ) {
253+ return null ;
254+ }
250255 }
251256
252257
Original file line number Diff line number Diff line change @@ -23,6 +23,14 @@ username = root
2323password = " Password12!"
2424system = mysql
2525
26+ [mysqli-driver]
27+ driver = mysqli
28+ host = 127.0.0.1
29+ username = root
30+ password = " Password12!"
31+ charset = utf8
32+ system = mysql
33+
2634[odbc]
2735driver = odbc
2836dsn = " Driver={Microsoft Access Driver (*.mdb, *.accdb)};Dbq=data/odbc.mdb"
Original file line number Diff line number Diff line change @@ -40,6 +40,15 @@ user = root
4040password = root
4141system = mysql
4242
43+ [mysqli-driver]
44+ driver = mysqli
45+ host = " 127.0.0.1"
46+ database = dibi_test
47+ username = root
48+ password = root
49+ port = 3307
50+ system = mysql
51+
4352[postgre 9.6]
4453driver = postgre
4554host = " 127.0.0.1"
Original file line number Diff line number Diff line change 1+ <?php
2+
3+ declare (strict_types=1 );
4+
5+ use Dibi \Drivers \MySqliDriver ;
6+ use Tester \Assert ;
7+
8+ require __DIR__ . '/bootstrap.php ' ;
9+
10+ //$rc = new \mysqli(
11+ // $config['host'],
12+ // $config['username'],
13+ // $config['password'],
14+ // $config['database'],
15+ // $config['port'],
16+ //);
17+ $ rc = new \mysqli (
18+ "127.0.0.1 " ,
19+ 'root ' ,
20+ 'root ' ,
21+ 'dibi_test ' ,
22+ 3306 ,
23+ );
24+
25+ $ driver = new MySqliDriver ([
26+ 'resource ' => $ rc ,
27+ ]);
28+
29+ // sanity check
30+ Assert::same ($ rc , $ driver ->getResource ());
31+
32+ // close the connection
33+ $ rc ->close ();
34+
35+ // This would trigger an error in PHP 8, see #409
36+ Assert::null ($ driver ->getResource ());
You can’t perform that action at this time.
0 commit comments