本文整理汇总了PHP中Toolbox::writeConfig方法的典型用法代码示例。如果您正苦于以下问题:PHP Toolbox::writeConfig方法的具体用法?PHP Toolbox::writeConfig怎么用?PHP Toolbox::writeConfig使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Toolbox
的用法示例。
在下文中一共展示了Toolbox::writeConfig方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: createSlaveConnectionFile
/**
* Create slave DB configuration file
*
* @param host the slave DB host(s)
* @param user the slave DB user
* @param password the slave DB password
* @param DBname the name of the slave DB
*
* @return boolean for success
**/
static function createSlaveConnectionFile($host, $user, $password, $DBname)
{
$DB_str = "<?php \n class DBSlave extends DBmysql { \n var \$slave = true; \n var \$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 .= " var \$dbuser = '" . $user . "'; \n var \$dbpassword= '" . rawurlencode($password) . "'; \n var \$dbdefault = '" . $DBname . "'; \n } \n ?>";
return Toolbox::writeConfig('config_db_slave.php', $DB_str);
}
示例2: create_conn_file
function create_conn_file($host, $user, $password, $DBname)
{
global $CFG_GLPI;
$DB_str = "<?php\n class DB extends DBmysql {\n \n var \$dbhost = '" . $host . "';\n \n var \$dbuser \t= '" . $user . "';\n \n var \$dbpassword= '" . rawurlencode($password) . "';\n \n var \$dbdefault\t= '" . $DBname . "';\n \n } \n?>";
return Toolbox::writeConfig('config_db.php', $DB_str);
}