【发布时间】:2014-01-07 17:56:33
【问题描述】:
我遇到了一个意外的异常。当我像这样更新数据时:
try {
$restaurantUpd = new Restaurant();
$restaurantUpd->updateRestaurant(array( 'restaurant_name' => Input::get('restaurant_name'),
'restaurant_location' => Input::get('restaurant_location'),
'restaurant_contact_email' => Input::get('restaurant_contact_email')
), $_GET['edit']);
//ok
} catch(Exception $e) {
die($e->getMessage());
}
它返回此错误:
Warning: require_once(classes/Exeption.php): failed to open stream: No such file or directory in C:\xampp\htdocs\admintest\core\init.php on line 32
但奇怪的是我没有Exeption.php 类?另外,第 32 行指的是我的自动加载:
/*
* Autoload function for classes
*/
spl_autoload_register(function($class) {
require_once 'classes/' . $class . '.php';
});
我在餐厅类的更新方法是这样的……
public function updateRestaurant($fields = array(), $id = null) {
if (!$this->_db->update('rt_restaurant', $id, $fields, false)) {
throw new Exeption('There was a problem updating');
}
}
DB 类的更新方法是 PDO 准备、执行、获取
有什么指导吗?
【问题讨论】:
-
Exeption表示可能有错别字 -
spl_autoload_register 如果找不到该类,则尝试请求文件,在您的程序中,它会尝试搜索在您的 CATCH 中调用的异常类,可能您使用的是旧版本的 PHP。请告诉您的 php 版本并检查它是否有异常类...
-
我的 php 版本号是最新的... PHP 版本 5.4.22
-
全局查找
Exeption.php;你几乎可以肯定在某个地方有错字。Exception.php是你想要的。 (注意c。) -
哇......刚刚编辑了我的问题以提供更多信息,现在我看到了我的错字......对不起,当它在堆栈上时溢出它似乎更清楚(它在类方法中)