[-] Installer: check create table privileges

This commit is contained in:
Rémi Gaillard
2013-02-01 18:36:35 +01:00
parent 6a261cbc66
commit 5490f6063d
5 changed files with 74 additions and 0 deletions

View File

@@ -174,6 +174,28 @@ class MySQLCore extends Db
@mysql_close($link);
return 0;
}
public static function checkCreatePrivilege($server, $user, $pwd, $db, $prefix, $engine)
{
ini_set('mysql.connect_timeout', 5);
if (!$link = @mysql_connect($server, $user, $pwd, true))
return false;
if (!@mysql_select_db($db, $link))
return false;
$sql = '
CREATE TABLE `'.$prefix.'test` (
`test` tinyint(1) unsigned NOT NULL
) ENGINE=MyISAM';
$result = mysql_query($sql, $link);
if (!$result)
return mysql_error($link);
mysql_query('DROP TABLE `'.$prefix.'test`', $link);
return true;
}
/**
* @see Db::checkEncoding()