Restore the connection check

This commit is contained in:
Michael 2020-11-07 11:44:39 +00:00
parent 1e52c430e6
commit eb8caaa5e7
2 changed files with 8 additions and 9 deletions

View file

@ -385,12 +385,11 @@ class Database
switch ($this->driver) {
case self::PDO:
$connected = true;
// $r = $this->p("SELECT 1");
// if ($this->isResult($r)) {
// $row = $this->toArray($r);
// $connected = ($row[0]['1'] == '1');
// }
$r = $this->p("SELECT 1");
if ($this->isResult($r)) {
$row = $this->toArray($r);
$connected = ($row[0]['1'] == '1');
}
break;
case self::MYSQLI:
$connected = $this->connection->ping();

View file

@ -119,9 +119,9 @@ class DependencyCheckTest extends TestCase
$database = $this->dice->create(Database::class);
self::assertInstanceOf(Database::class, $database);
self::assertContains($database->getDriver(), [Database::PDO, Database::MYSQLI]);
self::assertNotNull($database->getConnection());
self::assertTrue($database->connected());
self::assertContains($database->getDriver(), [Database::PDO, Database::MYSQLI], 'The driver returns an unexpected value');
self::assertNotNull($database->getConnection(), 'There is no database connection');
self::assertTrue($database->connected(), 'The database is not connected');
}
public function testAppMode()