Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
OpenDocCN
yii2_fecshop
提交
56953bd8
Y
yii2_fecshop
项目概览
OpenDocCN
/
yii2_fecshop
通知
18
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
Y
yii2_fecshop
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
56953bd8
编写于
7月 18, 2019
作者:
T
Terry
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
mysql 支持部分:ErrorHandler
上级
13e7d70f
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
63 addition
and
36 deletion
+63
-36
models/mysqldb/ErrorHandlerLog.php
models/mysqldb/ErrorHandlerLog.php
+25
-0
services/helper/ErrorHandler.php
services/helper/ErrorHandler.php
+38
-36
未找到文件。
models/mysqldb/ErrorHandlerLog.php
0 → 100644
浏览文件 @
56953bd8
<?php
/**
* FecShop file.
*
* @link http://www.fecshop.com/
* @copyright Copyright (c) 2016 FecShop Software LLC
* @license http://www.fecshop.com/license/
*/
namespace
fecshop\models\mysqldb
;
use
yii\db\ActiveRecord
;
/**
* @author Terry Zhao <2358269014@qq.com>
* @since 1.0
*/
// use fecshop\models\mysqldb\IpnMessage;
class
ErrorHandlerLog
extends
ActiveRecord
{
public
static
function
tableName
()
{
return
'{{%error_handler_log}}'
;
}
}
services/helper/ErrorHandler.php
浏览文件 @
56953bd8
...
...
@@ -20,20 +20,48 @@ use Yii;
*/
class
ErrorHandler
extends
Service
{
protected
$_errorHandlerModelName
=
'\fecshop\models\mongodb\ErrorHandlerLog'
;
/**
* $storagePrex , $storage , $storagePath 为找到当前的storage而设置的配置参数
* 可以在配置中更改,更改后,就会通过容器注入的方式修改相应的配置值
*/
public
$storage
=
'ErrorHandlerMysqldb'
;
// ErrorHandlerMysqldb | ErrorHandlerMongodb 当前的storage,如果在config中配置,那么在初始化的时候会被注入修改
protected
$_errorHandlerModel
;
/**
* 设置storage的path路径,
* 如果不设置,则系统使用默认路径
* 如果设置了路径,则使用自定义的路径
*/
public
$storagePath
=
''
;
protected
$_errorHandler
;
public
function
init
()
{
parent
::
init
();
list
(
$this
->
_errorHandlerModelName
,
$this
->
_errorHandlerModel
)
=
\
Yii
::
mapGet
(
$this
->
_errorHandlerModelName
);
$currentService
=
$this
->
getStorageService
(
$this
);
$this
->
_errorHandler
=
new
$currentService
();
}
// 动态更改为mongodb model
public
function
changeToMongoStorage
()
{
$this
->
storage
=
'ErrorHandlerMongodb'
;
$currentService
=
$this
->
getStorageService
(
$this
);
$this
->
_errorHandler
=
new
$currentService
();
}
// 动态更改为mongodb model
public
function
changeToMysqlStorage
()
{
$this
->
storage
=
'ErrorHandlerMysqldb'
;
$currentService
=
$this
->
getStorageService
(
$this
);
$this
->
_errorHandler
=
new
$currentService
();
}
public
function
getPrimaryKey
()
{
return
'_id'
;
return
$this
->
_errorHandler
->
getPrimaryKey
()
;
}
/**
* @param $code | Int, http 错误码
...
...
@@ -58,22 +86,9 @@ class ErrorHandler extends Service
$trace_string
,
$url
,
$req_info
=
[]
)
{
$category
=
Yii
::
$service
->
helper
->
getAppName
();
$model
=
new
$this
->
_errorHandlerModelName
();
$model
->
category
=
$category
;
$model
->
code
=
$code
;
$model
->
message
=
$message
;
$model
->
file
=
$file
;
$model
->
line
=
$line
;
$model
->
created_at
=
$created_at
;
$model
->
ip
=
$ip
;
$model
->
name
=
$name
;
$model
->
url
=
$url
;
$model
->
request_info
=
$req_info
;
$model
->
trace_string
=
$trace_string
;
$model
->
save
();
return
(
string
)
$model
[
$this
->
getPrimaryKey
()];
)
{
return
$this
->
_errorHandler
->
saveByErrorHandler
(
$code
,
$message
,
$file
,
$line
,
$created_at
,
$ip
,
$name
,
$trace_string
,
$url
,
$req_info
);
}
/**
...
...
@@ -81,9 +96,7 @@ class ErrorHandler extends Service
*/
public
function
getByPrimaryKey
(
$primaryKey
)
{
if
(
$primaryKey
)
{
return
$this
->
_errorHandlerModel
->
findOne
(
$primaryKey
);
}
return
$this
->
_errorHandler
->
getByPrimaryKey
(
$primaryKey
);
}
/*
...
...
@@ -100,19 +113,8 @@ class ErrorHandler extends Service
* 'asArray' => true,
* ]
*/
public
function
coll
(
$filter
=
''
)
public
function
coll
(
$filter
)
{
$query
=
$this
->
_errorHandlerModel
->
find
();
$query
=
Yii
::
$service
->
helper
->
ar
->
getCollByFilter
(
$query
,
$filter
);
$coll
=
$query
->
all
();
if
(
!
empty
(
$coll
))
{
foreach
(
$coll
as
$k
=>
$one
)
{
$coll
[
$k
]
=
$one
;
}
}
return
[
'coll'
=>
$coll
,
'count'
=>
$query
->
limit
(
null
)
->
offset
(
null
)
->
count
(),
];
return
$this
->
_errorHandler
->
coll
(
$filter
);
}
}
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录