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


PHP MDB::parseDSN方法代码示例

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


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

示例1: parseDSN

 function parseDSN($dsn)
 {
     return MDB::parseDSN($dsn);
 }
开发者ID:Esleelkartea,项目名称:kz-adeada-talleres-electricos-,代码行数:4,代码来源:peardb_wrapper.php

示例2: setDSN

 /**
  * set the DSN
  *
  * @param mixed     $dsninfo    DSN string or array
  * @return MDB_OK
  * @access public
  */
 function setDSN($dsn)
 {
     $dsninfo = MDB::parseDSN($dsn);
     if (isset($dsninfo['hostspec'])) {
         $this->host = $dsninfo['hostspec'];
     }
     if (isset($dsninfo['port'])) {
         $this->port = $dsninfo['port'];
     }
     if (isset($dsninfo['username'])) {
         $this->user = $dsninfo['username'];
     }
     if (isset($dsninfo['password'])) {
         $this->password = $dsninfo['password'];
     }
     if (isset($dsninfo['database'])) {
         $this->database_name = $dsninfo['database'];
     }
     return MDB_OK;
 }
开发者ID:Esleelkartea,项目名称:kz-adeada-talleres-electricos-,代码行数:27,代码来源:Common.php

示例3: array

 /**
  * Returns a MDB connection with the requested DSN.
  * A newnew MDB connection object is only created if no object with the
  * reuested DSN exists yet.
  *
  * IMPORTANT: In order for MDB to work properly it is necessary that
  * you make sure that you work with a reference of the original
  * object instead of a copy (this is a PHP4 quirk).
  *
  * For example:
  *     $mdb =& MDB::sngleton($dsn);
  *          ^^
  * And not:
  *     $mdb = MDB::singleton($dsn);
  *          ^^
  *
  * @param   mixed   $dsn      'data source name', see the MDB::parseDSN
  *                            method for a description of the dsn format.
  *                            Can also be specified as an array of the
  *                            format returned by MDB::parseDSN.
  * @param   mixed   $options  An associative array of option names and
  *                            their values.
  * @return  mixed   a newly created MDB connection object, or a MDB
  *                  error object on error
  * @access  public
  * @see     MDB::parseDSN
  */
 function &singleton($dsn = NULL, $options = FALSE)
 {
     if ($dsn) {
         $dsninfo = MDB::parseDSN($dsn);
         $dsninfo_default = array('phptype' => NULL, 'username' => NULL, 'password' => NULL, 'hostspec' => NULL, 'database' => NULL);
         $dsninfo = array_merge($dsninfo_default, $dsninfo);
         $keys = array_keys($GLOBALS['_MDB_databases']);
         for ($i = 0, $j = count($keys); $i < $j; ++$i) {
             $tmp_dsn = $GLOBALS['_MDB_databases'][$keys[$i]]->getDSN('array');
             if ($dsninfo['phptype'] == $tmp_dsn['phptype'] && $dsninfo['username'] == $tmp_dsn['username'] && $dsninfo['password'] == $tmp_dsn['password'] && $dsninfo['hostspec'] == $tmp_dsn['hostspec'] && $dsninfo['database'] == $tmp_dsn['database']) {
                 MDB::setOptions($GLOBALS['_MDB_databases'][$keys[$i]], $options);
                 return $GLOBALS['_MDB_databases'][$keys[$i]];
             }
         }
     } else {
         if (is_array($GLOBALS['_MDB_databases']) && reset($GLOBALS['_MDB_databases'])) {
             $db =& $GLOBALS['_MDB_databases'][key($GLOBALS['_MDB_databases'])];
             return $db;
         }
     }
     $db =& MDB::connect($dsn, $options);
     return $db;
 }
开发者ID:Esleelkartea,项目名称:kz-adeada-talleres-electricos-,代码行数:50,代码来源:MDB.php


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