prefering mysqli for new installs

This commit is contained in:
Ralf Becker 2013-05-26 09:43:10 +00:00
parent 3996f8a936
commit da74bf4210
2 changed files with 11 additions and 11 deletions

View File

@ -24,7 +24,7 @@ $config = array(
'domain' => 'default', 'domain' => 'default',
'config_user' => 'admin', 'config_user' => 'admin',
'config_passwd' => randomstring(), 'config_passwd' => randomstring(),
'db_type' => 'mysql', 'db_type' => 'mysqli',
'db_host' => 'localhost', 'db_host' => 'localhost',
'db_port' => 3306, 'db_port' => 3306,
'db_name' => 'egroupware', 'db_name' => 'egroupware',

View File

@ -19,10 +19,10 @@ class setup_cmd_database extends setup_cmd
* Allow to run this command via setup-cli * Allow to run this command via setup-cli
*/ */
const SETUP_CLI_CALLABLE = true; const SETUP_CLI_CALLABLE = true;
/** /**
* Maximum length of database name (at least for MySQL this is the limit) * Maximum length of database name (at least for MySQL this is the limit)
* *
* @var int * @var int
*/ */
const MAX_DB_NAME_LEN = 16; const MAX_DB_NAME_LEN = 16;
@ -68,7 +68,7 @@ class setup_cmd_database extends setup_cmd
'db_root_pw' => $db_root_pw, 'db_root_pw' => $db_root_pw,
'sub_command' => $sub_command, 'sub_command' => $sub_command,
'db_grant_host' => $db_grant_host, 'db_grant_host' => $db_grant_host,
'make_db_name_unique' => $make_db_name_unique, 'make_db_name_unique' => $make_db_name_unique,
); );
} }
//error_log(__METHOD__.'('.array2string($domain).") make_db_name_unique=".array2string($domain['make_db_name_unique'])); //error_log(__METHOD__.'('.array2string($domain).") make_db_name_unique=".array2string($domain['make_db_name_unique']));
@ -163,7 +163,7 @@ class setup_cmd_database extends setup_cmd
* Check and if does not yet exist create the new database and user * Check and if does not yet exist create the new database and user
* *
* The check will fail if the database exists, but already contains tables * The check will fail if the database exists, but already contains tables
* *
* if $this->make_db_name_unique is set, a decrementing nummeric prefix gets * if $this->make_db_name_unique is set, a decrementing nummeric prefix gets
* added to $this->db_name AND $this->db_user, if db already exists. * added to $this->db_name AND $this->db_user, if db already exists.
* *
@ -177,7 +177,7 @@ class setup_cmd_database extends setup_cmd
// shorten db-name/-user to self::MAX_DB_NAME_LEN chars // shorten db-name/-user to self::MAX_DB_NAME_LEN chars
if ($this->make_db_name_unique && strlen($this->db_name) > self::MAX_DB_NAME_LEN) if ($this->make_db_name_unique && strlen($this->db_name) > self::MAX_DB_NAME_LEN)
{ {
$this->set_defaults['db_name'] = $this->db_name = $this->set_defaults['db_name'] = $this->db_name =
$this->set_defaults['db_user'] = $this->db_user = // change user too (otherwise existing user/db could not connect any more!) $this->set_defaults['db_user'] = $this->db_user = // change user too (otherwise existing user/db could not connect any more!)
substr($this->db_name,0,self::MAX_DB_NAME_LEN); substr($this->db_name,0,self::MAX_DB_NAME_LEN);
} }
@ -193,7 +193,7 @@ class setup_cmd_database extends setup_cmd
catch(egw_exception_db $e) { // catches failed to create database catch(egw_exception_db $e) { // catches failed to create database
// try connect as root to check if wrong root/root_pw is the problem // try connect as root to check if wrong root/root_pw is the problem
$this->connect($this->db_root,$this->db_root_pw,$this->db_meta); $this->connect($this->db_root,$this->db_root_pw,$this->db_meta);
// if we should create a db with a unique name (try it only N times, not endless!) // if we should create a db with a unique name (try it only N times, not endless!)
if ($this->make_db_name_unique && $try_make_unique++ < 20) if ($this->make_db_name_unique && $try_make_unique++ < 20)
{ {
@ -209,10 +209,10 @@ class setup_cmd_database extends setup_cmd
{ {
$num = '2'; $num = '2';
} }
$this->set_defaults['db_name'] = $this->db_name = $this->set_defaults['db_name'] = $this->db_name =
$this->set_defaults['db_user'] = $this->db_user = // change user too (otherwise existing user/db could not connect any more!) $this->set_defaults['db_user'] = $this->db_user = // change user too (otherwise existing user/db could not connect any more!)
substr($this->db_name,0,self::MAX_DB_NAME_LEN-strlen($num)).$num; substr($this->db_name,0,self::MAX_DB_NAME_LEN-strlen($num)).$num;
return $this->create(); return $this->create();
} }
catch (egw_exception_wrong_userinput $e2) catch (egw_exception_wrong_userinput $e2)
@ -270,7 +270,7 @@ class setup_cmd_database extends setup_cmd
* @param string $db_type='mysql' * @param string $db_type='mysql'
* @return array * @return array
*/ */
static function defaults($db_type='mysql') static function defaults($db_type='mysqli')
{ {
switch($db_type) switch($db_type)
{ {
@ -312,7 +312,7 @@ class setup_cmd_database extends setup_cmd
if (strpos($this->$name,'$domain') !== false) if (strpos($this->$name,'$domain') !== false)
{ {
// limit names to 16 chars (16 char is user-name limit in MySQL) // limit names to 16 chars (16 char is user-name limit in MySQL)
$this->set_defaults[$name] = $this->$name = $this->set_defaults[$name] = $this->$name =
substr(str_replace(array('$domain','.','-'),array($this->domain,'_','_'),$this->$name), substr(str_replace(array('$domain','.','-'),array($this->domain,'_','_'),$this->$name),
0,self::MAX_DB_NAME_LEN); 0,self::MAX_DB_NAME_LEN);
} }