Skip to content

Commit a3215dc

Browse files
committed
Add Database::getConnection method
1 parent d29ba85 commit a3215dc

2 files changed

Lines changed: 18 additions & 0 deletions

File tree

src/Database.php

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -239,6 +239,16 @@ protected function setTimezone(string $timezone) : bool
239239
return $this->mysqli->real_query("SET time_zone = {$timezone}");
240240
}
241241

242+
/**
243+
* Gets the MySQLi connection.
244+
*
245+
* @return mysqli
246+
*/
247+
public function getConnection() : mysqli
248+
{
249+
return $this->mysqli;
250+
}
251+
242252
/**
243253
* Tells if the connection is open.
244254
*

tests/DatabaseTest.php

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -195,6 +195,14 @@ public function testConnectionFailWithFailover() : void
195195
]);
196196
}
197197

198+
public function testGetConnection() : void
199+
{
200+
self::assertInstanceOf(
201+
\mysqli::class,
202+
static::$database->getConnection()
203+
);
204+
}
205+
198206
/**
199207
* @runInSeparateProcess
200208
*/

0 commit comments

Comments
 (0)