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


PHP DB_DataObject::_autoloadClass方法代碼示例

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


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

示例1: _autoloadClass

 public function _autoloadClass($class, $table = false)
 {
     // avoid those annoying PEAR::DB strict standards warnings it causes
     $old = error_reporting();
     error_reporting(error_reporting() & ~E_STRICT);
     $res = parent::_autoloadClass($class, $table);
     // reset
     error_reporting($old);
     return $res;
 }
開發者ID:bashrc,項目名稱:gnusocial-debian,代碼行數:10,代碼來源:GS_DataObject.php

示例2: factory

 /**
  * classic factory method for loading a table class
  * usage: $do = DB_DataObject::factory('person')
  * WARNING - this may emit a include error if the file does not exist..
  * use @ to silence it (if you are sure it is acceptable)
  * eg. $do = @DB_DataObject::factory('person')
  *
  * table name can bedatabasename/table
  * - and allow modular dataobjects to be written..
  * (this also helps proxy creation)
  *
  * Experimental Support for Multi-Database factory eg. mydatabase.mytable
  * 
  * 
  * @param  string  $table  tablename (use blank to create a new instance of the same class.)
  * @access private
  * @return DataObject|PEAR_Error 
  */
 function factory($table = '')
 {
     global $_DB_DATAOBJECT;
     // multi-database support.. - experimental.
     $database = '';
     if (strpos($table, '/') !== false) {
         list($database, $table) = explode('.', $table, 2);
     }
     if (empty($_DB_DATAOBJECT['CONFIG'])) {
         DB_DataObject::_loadConfig();
     }
     // no configuration available for database
     if (!empty($database) && empty($_DB_DATAOBJECT['CONFIG']['database_' . $database])) {
         return DB_DataObject::raiseError("unable to find database_{$database} in Configuration, It is required for factory with database", 0, PEAR_ERROR_DIE);
     }
     if ($table === '') {
         if (is_a($this, 'DB_DataObject') && strlen($this->__table)) {
             $table = $this->__table;
         } else {
             return DB_DataObject::raiseError("factory did not recieve a table name", DB_DATAOBJECT_ERROR_INVALIDARGS);
         }
     }
     // does this need multi db support??
     $cp = isset($_DB_DATAOBJECT['CONFIG']['class_prefix']) ? explode(PATH_SEPARATOR, $_DB_DATAOBJECT['CONFIG']['class_prefix']) : '';
     // multiprefix support.
     $tbl = preg_replace('/[^A-Z0-9]/i', '_', ucfirst($table));
     if (is_array($cp)) {
         $class = array();
         foreach ($cp as $cpr) {
             $ce = substr(phpversion(), 0, 1) > 4 ? class_exists($cpr . $tbl, false) : class_exists($cpr . $tbl);
             if ($ce) {
                 $class = $cpr . $tbl;
                 break;
             }
             $class[] = $cpr . $tbl;
         }
     } else {
         $class = $tbl;
         $ce = substr(phpversion(), 0, 1) > 4 ? class_exists($class, false) : class_exists($class);
     }
     $rclass = $ce ? $class : DB_DataObject::_autoloadClass($class, $table);
     // proxy = full|light
     if (!$rclass && isset($_DB_DATAOBJECT['CONFIG']['proxy'])) {
         DB_DataObject::debug("FAILED TO Autoload  {$database}.{$table} - using proxy.", "FACTORY", 1);
         $proxyMethod = 'getProxy' . $_DB_DATAOBJECT['CONFIG']['proxy'];
         // if you have loaded (some other way) - dont try and load it again..
         class_exists('DB_DataObject_Generator') ? '' : (require_once 'DB/DataObject/Generator.php');
         $d = new DB_DataObject();
         $d->__table = $table;
         if (is_a($ret = $d->_connect(), 'PEAR_Error')) {
             return $ret;
         }
         $x = new DB_DataObject_Generator();
         return $x->{$proxyMethod}($d->_database, $table);
     }
     if (!$rclass) {
         return DB_DataObject::raiseError("factory could not find class " . (is_array($class) ? implode(PATH_SEPARATOR, $class) : $class) . "from {$table}", DB_DATAOBJECT_ERROR_INVALIDCONFIG);
     }
     $ret = new $rclass();
     if (!empty($database)) {
         DB_DataObject::debug("Setting database to {$database}", "FACTORY", 1);
         $ret->database($database);
     }
     return $ret;
 }
開發者ID:bigpussy,項目名稱:statusnet,代碼行數:83,代碼來源:DataObject.php

示例3: factory

 /**
  * classic factory method for loading a table class
  * usage: $do = DB_DataObject::factory('person')
  * WARNING - this may emit a include error if the file does not exist..
  * use @ to silence it (if you are sure it is acceptable)
  * eg. $do = @DB_DataObject::factory('person')
  *
  * table name will eventually be databasename/table
  * - and allow modular dataobjects to be written..
  * (this also helps proxy creation)
  *
  *
  * @param  string  $table  tablename (use blank to create a new instance of the same class.)
  * @access private
  * @return DataObject|PEAR_Error 
  */
 function factory($table = '')
 {
     global $_DB_DATAOBJECT;
     if (empty($_DB_DATAOBJECT['CONFIG'])) {
         DB_DataObject::_loadConfig();
     }
     if ($table === '') {
         if (is_a($this, 'DB_DataObject') && strlen($this->__table)) {
             $table = $this->__table;
         } else {
             return DB_DataObject::raiseError("factory did not recieve a table name", DB_DATAOBJECT_ERROR_INVALIDARGS);
         }
     }
     $p = isset($_DB_DATAOBJECT['CONFIG']['class_prefix']) ? $_DB_DATAOBJECT['CONFIG']['class_prefix'] : '';
     $class = $p . preg_replace('/[^A-Z0-9]/i', '_', ucfirst($table));
     $class = class_exists($class) ? $class : DB_DataObject::_autoloadClass($class);
     // proxy = full|light
     if (!$class && isset($_DB_DATAOBJECT['CONFIG']['proxy'])) {
         $proxyMethod = 'getProxy' . $_DB_DATAOBJECT['CONFIG']['proxy'];
         require_once 'DB/DataObject/Generator.php';
         $d = new DB_DataObject();
         $d->__table = $table;
         $d->_connect();
         $x = new DB_DataObject_Generator();
         return $x->{$proxyMethod}($d->_database, $table);
     }
     if (!$class) {
         return DB_DataObject::raiseError("factory could not find class {$class} from {$table}", DB_DATAOBJECT_ERROR_INVALIDCONFIG);
     }
     return new $class();
 }
開發者ID:bhirsch,項目名稱:voipdrupal-4.7-1.0,代碼行數:47,代碼來源:DataObject.php

示例4: m_autoload_db_dataobject

 public static function m_autoload_db_dataobject($class)
 {
     $classname = strtolower($class);
     if (strpos($classname, 'dataobjects_') === 0) {
         return DB_DataObject::_autoloadClass($classname);
     } else {
         return false;
     }
 }
開發者ID:demental,項目名稱:m,代碼行數:9,代碼來源:M.php

示例5: staticAutoloadTable

 /**
  * autoload Class relating to a table
  *
  * @param  string  $table  table
  * @access private
  * @return string classname on Success
  */
 function staticAutoloadTable($table)
 {
     global $_DB_DATAOBJECT;
     if (empty($_DB_DATAOBJECT['CONFIG'])) {
         DB_DataObject::_loadConfig();
     }
     $class = DB_DataObject::_autoloadClass($_DB_DATAOBJECT['CONFIG']['class_prefix'] . ucfirst($table));
     return $class;
 }
開發者ID:vojtajina,項目名稱:sitellite,代碼行數:16,代碼來源:DataObject.php


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