当前位置: 首页>>代码示例>>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;未经允许,请勿转载。