mirror of
https://github.com/alchemy-fr/Phraseanet.git
synced 2025-10-17 15:03:25 +00:00
PHRAS-288 Check if storage engines is available
This commit is contained in:
@@ -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();
|
||||
|
@@ -618,6 +618,10 @@ class databox extends base
|
||||
{
|
||||
$connection = new connection_pdo('test', $host, $port, $user, $password, $dbname, array(), $app['debug']);
|
||||
|
||||
if (false === $connection->supportInnoDB()) {
|
||||
throw new \Exception('Database server does not support InnoDB storage engine');
|
||||
}
|
||||
|
||||
$conn = $app['phraseanet.appbox']->get_connection();
|
||||
$sql = 'SELECT MAX(ord) as ord FROM sbas';
|
||||
$stmt = $conn->prepare($sql);
|
||||
|
Reference in New Issue
Block a user