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


PHP DB_DataObject::raiseError方法代码示例

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


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

示例1: _autoloadClass

 /**
  * autoload Class
  *
  * @param  string|array  $class  Class
  * @param  string  $table  Table trying to load.
  * @access private
  * @return string classname on Success
  */
 function _autoloadClass($class, $table = false)
 {
     global $_DB_DATAOBJECT;
     if (empty($_DB_DATAOBJECT['CONFIG'])) {
         DB_DataObject::_loadConfig();
     }
     $class_prefix = empty($_DB_DATAOBJECT['CONFIG']['class_prefix']) ? '' : $_DB_DATAOBJECT['CONFIG']['class_prefix'];
     $table = $table ? $table : substr($class, strlen($class_prefix));
     // only include the file if it exists - and barf badly if it has parse errors :)
     if (!empty($_DB_DATAOBJECT['CONFIG']['proxy']) || empty($_DB_DATAOBJECT['CONFIG']['class_location'])) {
         return false;
     }
     // support for:
     // class_location = mydir/ => maps to mydir/Tablename.php
     // class_location = mydir/myfile_%s.php => maps to mydir/myfile_Tablename
     // with directory sepr
     // class_location = mydir/:mydir2/: => tries all of thes locations.
     $cl = $_DB_DATAOBJECT['CONFIG']['class_location'];
     switch (true) {
         case strpos($cl, '%s') !== false:
             $file = sprintf($cl, preg_replace('/[^A-Z0-9]/i', '_', ucfirst($table)));
             break;
         case strpos($cl, PATH_SEPARATOR) !== false:
             $file = array();
             foreach (explode(PATH_SEPARATOR, $cl) as $p) {
                 $file[] = $p . '/' . preg_replace('/[^A-Z0-9]/i', '_', ucfirst($table)) . ".php";
             }
             break;
         default:
             $file = $cl . '/' . preg_replace('/[^A-Z0-9]/i', '_', ucfirst($table)) . ".php";
             break;
     }
     $cls = is_array($class) ? $class : array($class);
     if (is_array($file) || !file_exists($file)) {
         $found = false;
         $file = is_array($file) ? $file : array($file);
         $search = implode(PATH_SEPARATOR, $file);
         foreach ($file as $f) {
             foreach (explode(PATH_SEPARATOR, '' . PATH_SEPARATOR . ini_get('include_path')) as $p) {
                 $ff = empty($p) ? $f : "{$p}/{$f}";
                 if (file_exists($ff)) {
                     $file = $ff;
                     $found = true;
                     break;
                 }
             }
             if ($found) {
                 break;
             }
         }
         if (!$found) {
             DB_DataObject::raiseError("autoload:Could not find class " . implode(',', $cls) . " using class_location value :" . $search . " using include_path value :" . ini_get('include_path'), DB_DATAOBJECT_ERROR_INVALIDCONFIG);
             return false;
         }
     }
     include_once $file;
     $ce = false;
     foreach ($cls as $c) {
         $ce = substr(phpversion(), 0, 1) > 4 ? class_exists($c, false) : class_exists($c);
         if ($ce) {
             $class = $c;
             break;
         }
     }
     if (!$ce) {
         DB_DataObject::raiseError("autoload:Could not autoload " . implode(',', $cls), DB_DATAOBJECT_ERROR_INVALIDCONFIG);
         return false;
     }
     return $class;
 }
开发者ID:bigpussy,项目名称:statusnet,代码行数:78,代码来源:DataObject.php

示例2: _autoloadClass

 /**
  * autoload Class
  *
  * @param  string  $class  Class
  * @access private
  * @return string classname on Success
  */
 function _autoloadClass($class)
 {
     global $_DB_DATAOBJECT;
     if (empty($_DB_DATAOBJECT['CONFIG'])) {
         DB_DataObject::_loadConfig();
     }
     $table = substr($class, strlen($_DB_DATAOBJECT['CONFIG']['class_prefix']));
     // only include the file if it exists - and barf badly if it has parse errors :)
     if (!empty($_DB_DATAOBJECT['CONFIG']['proxy']) && empty($_DB_DATAOBJECT['CONFIG']['class_location'])) {
         return false;
     }
     if (strpos($_DB_DATAOBJECT['CONFIG']['class_location'], '%s') !== false) {
         $file = sprintf($_DB_DATAOBJECT['CONFIG']['class_location'], preg_replace('/[^A-Z0-9]/i', '_', ucfirst($table)));
     } else {
         $file = $_DB_DATAOBJECT['CONFIG']['class_location'] . '/' . preg_replace('/[^A-Z0-9]/i', '_', ucfirst($table)) . ".php";
     }
     if (!file_exists($file)) {
         $found = false;
         foreach (explode(PATH_SEPARATOR, ini_get('include_path')) as $p) {
             if (file_exists("{$p}/{$file}")) {
                 $file = "{$p}/{$file}";
                 $found = true;
                 break;
             }
         }
         if (!$found) {
             DB_DataObject::raiseError("autoload:Could not find class {$class} using class_location value", DB_DATAOBJECT_ERROR_INVALIDCONFIG);
             return false;
         }
     }
     include_once $file;
     if (!class_exists($class)) {
         DB_DataObject::raiseError("autoload:Could not autoload {$class}", DB_DATAOBJECT_ERROR_INVALIDCONFIG);
         return false;
     }
     return $class;
 }
开发者ID:bhirsch,项目名称:voipdrupal-4.7-1.0,代码行数:44,代码来源:DataObject.php

示例3: _autoloadClass

 /**
  * autoload Class
  *
  * @param  string  $class  Class
  * @access private
  * @return string classname on Success
  */
 function _autoloadClass($class)
 {
     global $_DB_DATAOBJECT;
     if (empty($_DB_DATAOBJECT['CONFIG'])) {
         DB_DataObject::_loadConfig();
     }
     $class_prefix = empty($_DB_DATAOBJECT['CONFIG']['class_prefix']) ? '' : $_DB_DATAOBJECT['CONFIG']['class_prefix'];
     $table = substr($class, strlen($class_prefix));
     // only include the file if it exists - and barf badly if it has parse errors :)
     if (!empty($_DB_DATAOBJECT['CONFIG']['proxy']) || empty($_DB_DATAOBJECT['CONFIG']['class_location'])) {
         return false;
     }
     // CHANGED FOR PLUGINS
     // array of plugin class locations
     // see DAL _setupDataObjectOptions
     if (!is_array($_DB_DATAOBJECT['CONFIG']['class_location'])) {
         $location = $_DB_DATAOBJECT['CONFIG']['class_location'];
         $file = DB_DataObject::findTableFile($location, $table);
     } else {
         foreach ($_DB_DATAOBJECT['CONFIG']['class_location'] as $k => $location) {
             $file = DB_DataObject::findTableFile($location, $table);
             if ($file) {
                 break;
             }
         }
     }
     if (!$file) {
         DB_DataObject::raiseError("autoload:Could not find class {$class} using class_location value", DB_DATAOBJECT_ERROR_INVALIDCONFIG);
         return false;
     }
     include_once $file;
     $ce = substr(phpversion(), 0, 1) > 4 ? class_exists($class, false) : class_exists($class);
     if (!$ce) {
         DB_DataObject::raiseError("autoload:Could not autoload {$class}", DB_DATAOBJECT_ERROR_INVALIDCONFIG);
         return false;
     }
     return $class;
 }
开发者ID:villos,项目名称:tree_admin,代码行数:45,代码来源:DataObject.php

示例4: deleteById

 /**
  * Delete record by it's primary key id
  *
  * @param int $primaryId
  * @param boolean $useWhere
  * @param boolean $cascadeDelete
  * @return boolean  True on success
  * @see DB_DataObjectCommon::delete()
  * @access public
  */
 function deleteById($primaryId, $useWhere = false, $cascadeDelete = true)
 {
     $keys = $this->keys();
     if (count($keys) != 1) {
         DB_DataObject::raiseError("no primary key defined or more than one pk in table '{$this->_tableName}'", DB_DATAOBJECT_ERROR_INVALIDARGS);
         return false;
     }
     $primaryKey = $keys[0];
     $this->{$primaryKey} = $primaryId;
     return $this->delete($useWhere, $cascadeDelete);
 }
开发者ID:Spark-Eleven,项目名称:revive-adserver,代码行数:21,代码来源:DB_DataObjectCommon.php

示例5: raiseError

 public function raiseError($message, $type = null, $behaviour = null)
 {
     $error = parent::raiseError($message, $type, $behaviour);
     throw new Exception($type . ' ' . $message . ' ' . $error->getUserInfo());
 }
开发者ID:demental,项目名称:m,代码行数:5,代码来源:Pluggable.php

示例6: setFrom

 /**
  * Copies items that are in the table definitions from an
  * array or object into the current object
  * will not override key values.
  *
  *
  * @param    array | object  $from
  * @param    string  $format eg. map xxxx_name to $object->name using 'xxxx_%s' (defaults to %s - eg. name -> $object->name
  * @access   public
  * @return   true on success or array of key=>setValue error message
  */
 function setFrom(&$from, $format = '%s')
 {
     global $_DB_DATAOBJECT;
     $keys = $this->_get_keys();
     $items = $this->_get_table();
     if (!$items) {
         DB_DataObject::raiseError("setFrom:Could not find table definition for {$this->__table}", DB_DATAOBJECT_ERROR_INVALIDCONFIG);
         return;
     }
     $overload_return = array();
     foreach (array_keys($items) as $k) {
         if (in_array($k, $keys)) {
             continue;
             // dont overwrite keys
         }
         if (!$k) {
             continue;
             // ignore empty keys!!! what
         }
         if (is_object($from) && isset($from->{sprintf($format, $k)})) {
             if ($_DB_DATAOBJECT['OVERLOADED']) {
                 $kk = strtolower($k) == 'from' ? '_from' : $k;
                 $ret = $this->{'set' . $kk}($from->{sprintf($format, $k)});
                 if (is_string($ret)) {
                     $overload_return[$k] = $ret;
                 }
                 continue;
             }
             $this->{$k} = $from->{sprintf($format, $k)};
             continue;
         }
         if (is_object($from)) {
             continue;
         }
         if (!isset($from[sprintf($format, $k)])) {
             continue;
         }
         if (is_object($from[sprintf($format, $k)])) {
             continue;
         }
         if (is_array($from[sprintf($format, $k)])) {
             continue;
         }
         if ($_DB_DATAOBJECT['OVERLOADED']) {
             $kk = strtolower($k) == 'from' ? '_from' : $k;
             $ret = $this->{'set' . $kk}($from[sprintf($format, $k)]);
             if (is_string($ret)) {
                 $overload_return[$k] = $ret;
             }
             continue;
         }
         $this->{$k} = $from[sprintf($format, $k)];
     }
     if ($overload_return) {
         return $overload_return;
     }
     return true;
 }
开发者ID:vojtajina,项目名称:sitellite,代码行数:69,代码来源:DataObject.php


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