[*] IN : removed the possibility to choose his own storage engine, automatically select the best one

This commit is contained in:
Damien Metzger
2013-06-26 14:26:37 +02:00
parent 9257dc80c2
commit 19ee2c953f
7 changed files with 105 additions and 85 deletions
+3 -1
View File
@@ -169,6 +169,8 @@ abstract class DbCore
/* do not remove, useful for some modules */
abstract public function set_db($db_name);
abstract public function getBestEngine();
/**
* Get Db object instance
@@ -674,7 +676,7 @@ abstract class DbCore
return call_user_func_array(array(Db::getClass(), 'hasTableWithSamePrefix'), array($server, $user, $pwd, $db, $prefix));
}
public static function checkCreatePrivilege($server, $user, $pwd, $db, $prefix, $engine)
public static function checkCreatePrivilege($server, $user, $pwd, $db, $prefix, $engine = null)
{
return call_user_func_array(array(Db::getClass(), 'checkCreatePrivilege'), array($server, $user, $pwd, $db, $prefix, $engine));
}
+26 -11
View File
@@ -172,21 +172,36 @@ class DbMySQLiCore extends Db
if (!$link->real_connect($server, $user, $pwd, $db))
return (mysqli_connect_errno() == 1049) ? 2 : 1;
if (strtolower($engine) == 'innodb')
{
$sql = 'SHOW VARIABLES WHERE Variable_name = \'have_innodb\'';
$result = $link->query($sql);
if (!$result)
return 4;
$row = $result->fetch_assoc();
if (!$row || strtolower($row['Value']) != 'yes')
return 4;
}
$link->close();
return 0;
}
public static function checkCreatePrivilege($server, $user, $pwd, $db, $prefix, $engine)
public function getBestEngine()
{
$value = 'InnoDB';
$sql = 'SHOW VARIABLES WHERE Variable_name = \'have_innodb\'';
$result = $link->query($sql);
if (!$result)
$value = 'MyISAM';
$row = $result->fetch_assoc();
if (!$row || strtolower($row['Value']) != 'yes')
$value = 'MyISAM';
/* MySQL >= 5.6 */
$sql = 'SHOW ENGINES';
$result = $link->query($sql);
while ($row = $result->fetch_assoc())
if ($row['Engine'] == 'InnoDB')
{
if (in_array($row['Support'], array('DEFAULT', 'YES')))
$value = 'InnoDB';
break;
}
return $value;
}
public static function checkCreatePrivilege($server, $user, $pwd, $db, $prefix, $engine = null)
{
$link = @new mysqli($server, $user, $pwd, $db);
if (mysqli_connect_error())
+26 -26
View File
@@ -174,7 +174,7 @@ class DbPDOCore extends Db
return (bool)$result->fetch();
}
public static function checkCreatePrivilege($server, $user, $pwd, $db, $prefix, $engine)
public static function checkCreatePrivilege($server, $user, $pwd, $db, $prefix, $engine = null)
{
try {
$link = DbPDO::_getPDO($server, $user, $pwd, $db, 5);
@@ -206,34 +206,34 @@ class DbPDOCore extends Db
} catch (PDOException $e) {
return ($e->getCode() == 1049) ? 2 : 1;
}
if (strtolower($engine) == 'innodb')
{
$value = 0;
$sql = 'SHOW VARIABLES WHERE Variable_name = \'have_innodb\'';
$result = $link->query($sql);
if (!$result)
$value = 4;
$row = $result->fetch();
if (!$row || strtolower($row['Value']) != 'yes')
$value = 4;
/* MySQL >= 5.6 */
$sql = 'SHOW ENGINES';
$result = $link->query($sql);
while ($row = $result->fetch())
if ($row['Engine'] == 'InnoDB')
{
if (in_array($row['Support'], array('DEFAULT', 'YES')))
$value = 0;
break;
}
return $value;
}
unset($link);
return 0;
}
public function getBestEngine()
{
$value = 'InnoDB';
$sql = 'SHOW VARIABLES WHERE Variable_name = \'have_innodb\'';
$result = $link->query($sql);
if (!$result)
$value = 'MyISAM';
$row = $result->fetch();
if (!$row || strtolower($row['Value']) != 'yes')
$value = 'MyISAM';
/* MySQL >= 5.6 */
$sql = 'SHOW ENGINES';
$result = $link->query($sql);
while ($row = $result->fetch())
if ($row['Engine'] == 'InnoDB')
{
if (in_array($row['Support'], array('DEFAULT', 'YES')))
$value = 'InnoDB';
break;
}
return $value;
}
/**
* @see Db::checkEncoding()
+26 -26
View File
@@ -165,36 +165,36 @@ class MySQLCore extends Db
return 1;
if (!@mysql_select_db($db, $link))
return 2;
if (strtolower($engine) == 'innodb')
{
$value = 0;
$sql = 'SHOW VARIABLES WHERE Variable_name = \'have_innodb\'';
$result = mysql_query($sql);
if (!$result)
$value = 4;
$row = mysql_fetch_assoc($result);
if (!$row || strtolower($row['Value']) != 'yes')
$value = 4;
/* MySQL >= 5.6 */
$sql = 'SHOW ENGINES';
$result = mysql_query($sql);
while ($row = mysql_fetch_assoc($result))
if ($row['Engine'] == 'InnoDB')
{
if (in_array($row['Support'], array('DEFAULT', 'YES')))
$value = 0;
break;
}
return $value;
}
@mysql_close($link);
return 0;
}
public function getBestEngine()
{
$value = 'InnoDB';
$sql = 'SHOW VARIABLES WHERE Variable_name = \'have_innodb\'';
$result = mysql_query($sql);
if (!$result)
$value = 'MyISAM';
$row = mysql_fetch_assoc($result);
if (!$row || strtolower($row['Value']) != 'yes')
$value = 'MyISAM';
/* MySQL >= 5.6 */
$sql = 'SHOW ENGINES';
$result = mysql_query($sql);
while ($row = mysql_fetch_assoc($result))
if ($row['Engine'] == 'InnoDB')
{
if (in_array($row['Support'], array('DEFAULT', 'YES')))
$value = 'InnoDB';
break;
}
return $value;
}
public static function checkCreatePrivilege($server, $user, $pwd, $db, $prefix, $engine)
public static function checkCreatePrivilege($server, $user, $pwd, $db, $prefix, $engine = null)
{
ini_set('mysql.connect_timeout', 5);
if (!$link = @mysql_connect($server, $user, $pwd, true))