mirror of
https://gitee.com/fastadminnet/framework.git
synced 2026-07-07 07:12:47 +08:00
改进异常类
This commit is contained in:
@@ -1,43 +0,0 @@
|
||||
<?php
|
||||
// +----------------------------------------------------------------------
|
||||
// | ThinkPHP [ WE CAN DO IT JUST THINK ]
|
||||
// +----------------------------------------------------------------------
|
||||
// | Copyright (c) 2006~2016 http://thinkphp.cn All rights reserved.
|
||||
// +----------------------------------------------------------------------
|
||||
// | Licensed ( http://www.apache.org/licenses/LICENSE-2.0 )
|
||||
// +----------------------------------------------------------------------
|
||||
// | Author: 麦当苗儿 <zuojiazi@vip.qq.com> <http://zjzit.cn>
|
||||
// +----------------------------------------------------------------------
|
||||
|
||||
namespace think\db;
|
||||
|
||||
use think\Exception;
|
||||
|
||||
/**
|
||||
* Database相关异常处理类
|
||||
*/
|
||||
class DbException extends Exception
|
||||
{
|
||||
/**
|
||||
* DbException constructor.
|
||||
* @param string $message
|
||||
* @param array $config
|
||||
* @param string $sql
|
||||
* @param int $code
|
||||
*/
|
||||
public function __construct($message, Array $config, $sql, $code = 10500)
|
||||
{
|
||||
$this->message = $message;
|
||||
$this->code = $code;
|
||||
|
||||
$this->setData('Database Status', [
|
||||
'Error Code' => $code,
|
||||
'Error Message' => $message,
|
||||
'Error SQL' => $sql
|
||||
]);
|
||||
|
||||
$this->setData('Database Config', $config);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
@@ -18,9 +18,10 @@ use think\Config;
|
||||
use think\Db;
|
||||
use think\db\Builder;
|
||||
use think\db\Connection;
|
||||
use think\db\DbException;
|
||||
use think\Exception;
|
||||
use think\exception\DbException;
|
||||
use think\exception\PDOException;
|
||||
use think\db\exception\BindParamException;
|
||||
use think\db\exception\ModelNotFoundException;
|
||||
use think\db\exception\DataNotFoundException;
|
||||
use think\Loader;
|
||||
@@ -179,7 +180,7 @@ class Query
|
||||
* @param boolean $master 是否在主服务器读操作
|
||||
* @param bool|string $class 指定返回的数据集对象
|
||||
* @return mixed
|
||||
* @throws DbBindParamException
|
||||
* @throws BindParamException
|
||||
* @throws PDOException
|
||||
*/
|
||||
public function query($sql, $bind = [], $fetch = false, $master = false, $class = false)
|
||||
@@ -196,7 +197,7 @@ class Query
|
||||
* @param boolean $getLastInsID 是否获取自增ID
|
||||
* @param boolean $sequence 自增序列名
|
||||
* @return int
|
||||
* @throws DbBindParamException
|
||||
* @throws BindParamException
|
||||
* @throws PDOException
|
||||
*/
|
||||
public function execute($sql, $bind = [], $fetch = false, $getLastInsID = false, $sequence = null)
|
||||
|
||||
@@ -11,16 +11,16 @@
|
||||
|
||||
namespace think\db\exception;
|
||||
|
||||
use think\db\Exception;
|
||||
use think\exception\DbException;
|
||||
|
||||
/**
|
||||
* PDO参数绑定异常
|
||||
*/
|
||||
class BindParamException extends Exception
|
||||
class BindParamException extends DbException
|
||||
{
|
||||
|
||||
/**
|
||||
* DbBindParamException constructor.
|
||||
* BindParamException constructor.
|
||||
* @param string $message
|
||||
* @param array $config
|
||||
* @param string $sql
|
||||
|
||||
@@ -11,7 +11,7 @@
|
||||
|
||||
namespace think\db\exception;
|
||||
|
||||
use think\db\DbException;
|
||||
use think\exception\DbException;
|
||||
|
||||
class DataNotFoundException extends DbException
|
||||
{
|
||||
|
||||
@@ -11,7 +11,7 @@
|
||||
|
||||
namespace think\db\exception;
|
||||
|
||||
use think\db\DbException;
|
||||
use think\exception\DbException;
|
||||
|
||||
class ModelNotFoundException extends DbException
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user