本文整理汇总了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;
}
示例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;
}
示例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;
}
示例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);
}
示例5: raiseError
public function raiseError($message, $type = null, $behaviour = null)
{
$error = parent::raiseError($message, $type, $behaviour);
throw new Exception($type . ' ' . $message . ' ' . $error->getUserInfo());
}
示例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;
}