当前位置: 首页>>代码示例>>PHP>>正文


PHP rcube_db::parse_dsn方法代码示例

本文整理汇总了PHP中rcube_db::parse_dsn方法的典型用法代码示例。如果您正苦于以下问题:PHP rcube_db::parse_dsn方法的具体用法?PHP rcube_db::parse_dsn怎么用?PHP rcube_db::parse_dsn使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在rcube_db的用法示例。


在下文中一共展示了rcube_db::parse_dsn方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: init_db

 /**
  * Wipe and re-initialize (mysql) database
  */
 public static function init_db()
 {
     $rcmail = rcmail::get_instance();
     $dsn = rcube_db::parse_dsn($rcmail->config->get('db_dsnw'));
     if ($dsn['phptype'] == 'mysql' || $dsn['phptype'] == 'mysqli') {
         // drop all existing tables first
         $db = $rcmail->get_dbh();
         $db->query("SET FOREIGN_KEY_CHECKS=0");
         $sql_res = $db->query("SHOW TABLES");
         while ($sql_arr = $db->fetch_array($sql_res)) {
             $table = reset($sql_arr);
             $db->query("DROP TABLE {$table}");
         }
         // init database with schema
         system(sprintf('cat %s %s | mysql -h %s -u %s --password=%s %s', realpath(INSTALL_PATH . '/SQL/mysql.initial.sql'), realpath(TESTS_DIR . 'Selenium/data/mysql.sql'), escapeshellarg($dsn['hostspec']), escapeshellarg($dsn['username']), escapeshellarg($dsn['password']), escapeshellarg($dsn['database'])));
     } else {
         if ($dsn['phptype'] == 'sqlite') {
             // delete database file -- will be re-initialized on first access
             system(sprintf('rm -f %s', escapeshellarg($dsn['database'])));
         }
     }
 }
开发者ID:noikiy,项目名称:roundcubemail,代码行数:25,代码来源:bootstrap.php

示例2: html_select

<dl class="configblock" id="cgfblockdb">
<dt class="propname">db_dsnw</dt>
<dd>
<p>Database settings for read/write operations:</p>
<?php 
$select_dbtype = new html_select(array('name' => '_dbtype', 'id' => "cfgdbtype"));
foreach ($RCI->supported_dbs as $database => $ext) {
    if (extension_loaded($ext)) {
        $select_dbtype->add($database, substr($ext, 4));
    }
}
$input_dbhost = new html_inputfield(array('name' => '_dbhost', 'size' => 20, 'id' => "cfgdbhost"));
$input_dbname = new html_inputfield(array('name' => '_dbname', 'size' => 20, 'id' => "cfgdbname"));
$input_dbuser = new html_inputfield(array('name' => '_dbuser', 'size' => 20, 'id' => "cfgdbuser"));
$input_dbpass = new html_passwordfield(array('name' => '_dbpass', 'size' => 20, 'id' => "cfgdbpass"));
$dsnw = rcube_db::parse_dsn($RCI->getprop('db_dsnw'));
echo $select_dbtype->show($RCI->is_post ? $_POST['_dbtype'] : $dsnw['phptype']);
echo '<label for="cfgdbtype">Database type</label><br />';
echo $input_dbhost->show($RCI->is_post ? $_POST['_dbhost'] : $dsnw['hostspec']);
echo '<label for="cfgdbhost">Database server (omit for sqlite)</label><br />';
echo $input_dbname->show($RCI->is_post ? $_POST['_dbname'] : $dsnw['database']);
echo '<label for="cfgdbname">Database name (use absolute path and filename for sqlite)</label><br />';
echo $input_dbuser->show($RCI->is_post ? $_POST['_dbuser'] : $dsnw['username']);
echo '<label for="cfgdbuser">Database user name (needs write permissions)(omit for sqlite)</label><br />';
echo $input_dbpass->show($RCI->is_post ? $_POST['_dbpass'] : $dsnw['password']);
echo '<label for="cfgdbpass">Database password (omit for sqlite)</label><br />';
?>
</dd>

<dt class="propname">db_prefix</dt>
<dd>
开发者ID:StudsPro,项目名称:islandpeeps.com,代码行数:31,代码来源:config.php


注:本文中的rcube_db::parse_dsn方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。