當前位置: 首頁>>代碼示例>>PHP>>正文


PHP Toolbox::writeConfig方法代碼示例

本文整理匯總了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);
 }
開發者ID:pvasener,項目名稱:glpi,代碼行數:34,代碼來源:dbconnection.class.php

示例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);
}
開發者ID:paisdelconocimiento,項目名稱:glpi-smartcities,代碼行數:6,代碼來源:install.php


注:本文中的Toolbox::writeConfig方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。