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


PHP MDB2_Driver_Common::setFetchMode方法代码示例

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


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

示例1: __construct

 /**
  * Constructor
  *
  * @param MDB2_Driver_Common $db An instance of MDB2_Driver_Common.
  *
  * @throws XML_Query2XML_DBException If the fetch mode cannot be set to
  *                               MDB2_FETCHMODE_ASSOC.
  */
 public function __construct(MDB2_Driver_Common $db)
 {
     $fetchModeError = $db->setFetchMode(MDB2_FETCHMODE_ASSOC);
     if (PEAR::isError($fetchModeError)) {
         throw new XML_Query2XML_DBException('Could not set fetch mode to DB_FETCHMODE_ASSOC: ' . $fetchModeError->toString());
     }
     $this->_db = $db;
 }
开发者ID:quangbt2005,项目名称:vhost-kis,代码行数:16,代码来源:MDB2.php

示例2: connectMDB2

 /**
  * connect to the database using mdb2
  */
 public static function connectMDB2()
 {
     if (self::$connection) {
         if (self::$backend == self::BACKEND_PDO) {
             self::disconnect();
         } else {
             return true;
         }
     }
     // The global data we need
     $name = OC_Config::getValue("dbname", "owncloud");
     $host = OC_Config::getValue("dbhost", "");
     $user = OC_Config::getValue("dbuser", "");
     $pass = OC_Config::getValue("dbpassword", "");
     $type = OC_Config::getValue("dbtype", "sqlite");
     $SERVERROOT = OC::$SERVERROOT;
     $datadir = OC_Config::getValue("datadirectory", "{$SERVERROOT}/data");
     // do nothing if the connection already has been established
     if (!self::$MDB2) {
         // Require MDB2.php (not required in the head of the file so we only load it when needed)
         require_once 'MDB2.php';
         // Prepare options array
         $options = array('portability' => MDB2_PORTABILITY_ALL - MDB2_PORTABILITY_FIX_CASE, 'log_line_break' => '<br>', 'idxname_format' => '%s', 'debug' => true, 'quote_identifier' => true);
         // Add the dsn according to the database type
         switch ($type) {
             case 'sqlite':
             case 'sqlite3':
                 $dsn = array('phptype' => $type, 'database' => "{$datadir}/{$name}.db", 'mode' => '0644');
                 break;
             case 'mysql':
                 $dsn = array('phptype' => 'mysql', 'username' => $user, 'password' => $pass, 'hostspec' => $host, 'database' => $name);
                 break;
             case 'pgsql':
                 $dsn = array('phptype' => 'pgsql', 'username' => $user, 'password' => $pass, 'hostspec' => $host, 'database' => $name);
                 break;
             case 'oci':
                 $dsn = array('phptype' => 'oci8', 'username' => $user, 'password' => $pass, 'charset' => 'AL32UTF8');
                 if ($host != '') {
                     $dsn['hostspec'] = $host;
                     $dsn['database'] = $name;
                 } else {
                     // use dbname for hostspec
                     $dsn['hostspec'] = $name;
                     $dsn['database'] = $user;
                 }
                 break;
             default:
                 return false;
         }
         // Try to establish connection
         self::$MDB2 = MDB2::factory($dsn, $options);
         // Die if we could not connect
         if (PEAR::isError(self::$MDB2)) {
             OC_Log::write('core', self::$MDB2->getUserInfo(), OC_Log::FATAL);
             OC_Log::write('core', self::$MDB2->getMessage(), OC_Log::FATAL);
             OC_Template::printErrorPage('can not connect to database, using ' . $type . '. (' . self::$MDB2->getUserInfo() . ')');
         }
         // We always, really always want associative arrays
         self::$MDB2->setFetchMode(MDB2_FETCHMODE_ASSOC);
     }
     // we are done. great!
     return true;
 }
开发者ID:ryanshoover,项目名称:core,代码行数:66,代码来源:db.php


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