當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。