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


PHP parent::db方法代码示例

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


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

示例1: singleton

 /**
  * Create a singleton of ADODB or ADODBLite;  This driver works for 
  * both.  Just specify the correct directory in 
  * config->db->options->adodbDir.
  * The directory in which adodbDir resides in must be in your
  * include_path.
  *
  * @access public
  * @throws Framework_DB_Exception on failure
  * @return object                 Instance of ADODB[Lite] connected to the DB
  */
 public function singleton()
 {
     if (!is_null(parent::$db) && parent::$db instanceof ADOConnection) {
         return parent::$db;
     }
     // Manually include files, ADODB does not follow naming conventions
     if (empty($this->options->adodbDir)) {
         throw new Framework_DB_Exception('Error: you must set $config->db->options->adodbDir');
     }
     $path = (string) $this->options->adodbDir . DIRECTORY_SEPARATOR;
     if (!(include_once $path . 'adodb-exceptions.inc.php') || !(include_once $path . 'adodb.inc.php')) {
         throw new Framework_DB_Exception('Error: could not include ADODB files');
     }
     // Connect
     try {
         parent::$db = ADONewConnection($this->dsn);
     } catch (Exception $error) {
         throw new Framework_DB_Exception($error->getMessage(), $error->getCode());
     }
     // Fetch Modes
     $fetchModes = array('ADODB_FETCH_DEFAULT' => ADODB_FETCH_DEFAULT, 'ADODB_FETCH_NUM' => ADODB_FETCH_NUM, 'ADODB_FETCH_ASSOC' => ADODB_FETCH_ASSOC, 'ADODB_FETCH_BOTH' => ADODB_FETCH_BOTH);
     $fetchMode = ADODB_FETCH_ASSOC;
     if (isset($this->options->fetchMode) && isset($fetchModes[(string) $this->options->fetchMode])) {
         $fetchMode = $fetchModes[(string) $this->options->fetchMode];
     }
     parent::$db->SetFetchMode($fetchMode);
     return parent::$db;
 }
开发者ID:shupp,项目名称:Framework,代码行数:39,代码来源:ADODB.php

示例2: singleton

 /**
  * Create a singleton of PEAR's DB 
  *
  * @access      public
  * @return      object      Instance of PEAR DB connected to the DB
  * @throws      Framework_DB_Exception
  */
 public function singleton()
 {
     if (!is_null(parent::$db) && parent::$db instanceof MDB2_Driver_Common) {
         return parent::$db;
     }
     parent::$db = MDB2::connect($this->dsn);
     if (PEAR::isError(parent::$db)) {
         throw new Framework_DB_Exception(parent::$db->getMessage(), parent::$db->getCode());
     }
     $fetchMode = MDB2_FETCHMODE_ASSOC;
     if (isset($this->options->fetchMode) && isset(self::$fetchModes[(string) $this->options->fetchMode])) {
         $fetchMode = self::$fetchModes[(string) $this->options->fetchMode];
     }
     parent::$db->setFetchMode($fetchMode);
     return parent::$db;
 }
开发者ID:joestump,项目名称:framework,代码行数:23,代码来源:MDB2.php

示例3: __construct

 public function __construct($id = '')
 {
     parent::$db = self::$db;
     parent::__construct($id);
 }
开发者ID:hendisantika,项目名称:ajax-crud-bootstrap,代码行数:5,代码来源:user.php

示例4: init

 public static function init()
 {
     global $discuz;
     parent::$db = $discuz->db;
 }
开发者ID:herosrx,项目名称:shops,代码行数:5,代码来源:base.php


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