PHRAS-288 Check if storage engines is available

This commit is contained in:
Nicolas Le Goff
2015-01-12 16:42:38 +01:00
parent 0275ede43c
commit 99bc7d0e65
6 changed files with 53 additions and 3 deletions

View File

@@ -59,6 +59,27 @@ abstract class connection_abstract
return $this->connection->getAttribute(constant("PDO::ATTR_SERVER_VERSION"));
}
public function supportInnoDB()
{
if (false === $this->ping()) {
throw new \Exception('Mysql server is not reachable');
}
$stmt = $this->connection->query('SHOW ENGINES');
$stmt->execute();
$engines = $stmt->fetchAll(\PDO::FETCH_ASSOC);
foreach ($engines as $engine) {
if (strtolower($engine['Engine']) !== 'innodb') {
continue;
}
return $engine['Support'] !== 'NO';
}
return false;
}
public function __destruct()
{
$this->close();