static function createSlaveConnectionFile($host, $user, $password, $DBname)
{
$DB_str = "<?php \n class DBSlave extends DBmysql { \n public \$slave = true; \n public \$dbhost = ";
$host = trim($host);
if (strpos($host, ' ')) {
$hosts = explode(' ', $host);
$first = true;
foreach ($hosts as $host) {
if (!empty($host)) {
$DB_str .= ($first ? "array('" : ",'") . $host . "'";
$first = false;
}
}
if ($first) {
// no host configured
return false;
}
$DB_str .= ");\n";
} else {
$DB_str .= "'{$host}';\n";
}
$DB_str .= " public \$dbuser = '" . $user . "'; \n public \$dbpassword= '" . rawurlencode($password) . "'; \n public \$dbdefault = '" . $DBname . "'; \n }\n";
return Toolbox::writeConfig('config_db_slave.php', $DB_str);
}