當前位置: 首頁>>代碼示例>>PHP>>正文


PHP DBAdapter::factory方法代碼示例

本文整理匯總了PHP中DBAdapter::factory方法的典型用法代碼示例。如果您正苦於以下問題:PHP DBAdapter::factory方法的具體用法?PHP DBAdapter::factory怎麽用?PHP DBAdapter::factory使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在DBAdapter的用法示例。


在下文中一共展示了DBAdapter::factory方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: initAdapters

 /**
  * Setup the adapters needed.  An adapter must be defined for each database connection.
  * Generally the adapter will be the same as the PEAR phpname; e.g. for MySQL, use the
  * 'mysql' adapter.
  * @param      array $configuration the Configuration representing the properties file
  * @throws     PropelException Any exceptions caught during processing will be
  *		 rethrown wrapped into a PropelException.
  */
 private static function initAdapters($configuration)
 {
     self::$adapterMap = array();
     $c = isset($configuration['datasources']) ? $configuration['datasources'] : null;
     if (!empty($c)) {
         try {
             foreach ($c as $handle => $properties) {
                 if (is_array($properties) && isset($properties['adapter'])) {
                     $db = DBAdapter::factory($properties['adapter']);
                     // register the adapter for this name
                     self::$adapterMap[$handle] = $db;
                 }
             }
         } catch (Exception $e) {
             throw new PropelException("Unable to initialize adapters.", $e);
         }
     } else {
         self::log("There were no adapters in the configuration.", self::LOG_WARNING);
     }
 }
開發者ID:bqevin,項目名稱:processmaker,代碼行數:28,代碼來源:Propel.php

示例2: getDB

 /**
  * Returns database adapter for a specific datasource.
  *
  * @param      string The datasource name.
  *
  * @return     DBAdapter The corresponding database adapter.
  *
  * @throws     PropelException If unable to find DBdapter for specified db.
  */
 public static function getDB($name = null)
 {
     if ($name === null) {
         $name = self::getDefaultDB();
     }
     if (!isset(self::$adapterMap[$name])) {
         if (!isset(self::$configuration['datasources'][$name]['adapter'])) {
             throw new PropelException("Unable to find adapter for datasource [" . $name . "].");
         }
         $db = DBAdapter::factory(self::$configuration['datasources'][$name]['adapter']);
         // register the adapter for this name
         self::$adapterMap[$name] = $db;
     }
     return self::$adapterMap[$name];
 }
開發者ID:pgodel,項目名稱:PageRoller,代碼行數:24,代碼來源:Propel.php


注:本文中的DBAdapter::factory方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。