Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
P
php_utils
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
bp
php_utils
Commits
4fb2b99e
Commit
4fb2b99e
authored
Aug 12, 2021
by
cuiweifeng
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
update: 报警邮件发送自定义
parent
866e88e9
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
11 additions
and
2 deletions
+11
-2
MysqlBase.php
src/Mysql/MysqlBase.php
+11
-2
No files found.
src/Mysql/MysqlBase.php
View file @
4fb2b99e
...
@@ -24,6 +24,7 @@ use Api\PhpUtils\Log\FileLog;
...
@@ -24,6 +24,7 @@ use Api\PhpUtils\Log\FileLog;
* $options参数可选项:
* $options参数可选项:
* - $options['max_execution_time'] = 10; // 单位毫秒
* - $options['max_execution_time'] = 10; // 单位毫秒
* - $options['rowCount'] = true; // 返回insert后的影响行数
* - $options['rowCount'] = true; // 返回insert后的影响行数
* - $options['alertMail'] = true; // SQL执行出错是否发送报警邮件标识,默认发送
* @see https://medoo.in (英文网站)
* @see https://medoo.in (英文网站)
* @see https://medoo.lvtao.net (中文网站)
* @see https://medoo.lvtao.net (中文网站)
...
@@ -37,7 +38,7 @@ use Api\PhpUtils\Log\FileLog;
...
@@ -37,7 +38,7 @@ use Api\PhpUtils\Log\FileLog;
* @method static MysqlBase select($columns, $where, $options)
* @method static MysqlBase select($columns, $where, $options)
* @method static MysqlBase selectMaster($columns, $where, $options)
* @method static MysqlBase selectMaster($columns, $where, $options)
* @method static MysqlBase selectForUpdate($columns, $where, $options)
* @method static MysqlBase selectForUpdate($columns, $where, $options)
*
*
@method static MysqlBase selectForUpdateSkipLocked($columns, $where, $options)
* @method static MysqlBase selectForUpdateSkipLocked($columns, $where, $options)
* @method static MysqlBase getMaster($columns, $where, $options)
* @method static MysqlBase getMaster($columns, $where, $options)
* @method static MysqlBase get($columns, $where, $options)
* @method static MysqlBase get($columns, $where, $options)
* @method static MysqlBase count($columns, $where)
* @method static MysqlBase count($columns, $where)
...
@@ -329,7 +330,15 @@ abstract class MysqlBase
...
@@ -329,7 +330,15 @@ abstract class MysqlBase
return
true
;
return
true
;
}
}
FileLog
::
error
(
"mysql error catch:"
.
$method
.
"-"
.
json_encode
(
$arguments
)
.
'-'
.
print_r
([
$sqlState
,
$errorCode
,
$errorMessage
],
1
));
if
(
in_array
(
strtolower
(
$method
),
[
'insert'
])
&&
isset
(
$arguments
[
2
][
'alertMail'
])
&&
$arguments
[
2
][
'alertMail'
]
===
false
)
{
FileLog
::
info
(
"mysql info catch:"
.
$method
.
"-"
.
json_encode
(
$arguments
)
.
'-'
.
print_r
([
$sqlState
,
$errorCode
,
$errorMessage
],
1
));
}
elseif
(
in_array
(
strtolower
(
$method
),
[
'select'
,
'selectmaster'
,
'selectforupdate'
,
'get'
,
'getmaster'
])
&&
isset
(
$arguments
[
3
][
'alertMail'
])
&&
$arguments
[
3
][
'alertMail'
]
===
false
)
{
FileLog
::
info
(
"mysql info catch:"
.
$method
.
"-"
.
json_encode
(
$arguments
)
.
'-'
.
print_r
([
$sqlState
,
$errorCode
,
$errorMessage
],
1
));
}
else
{
FileLog
::
error
(
"mysql error catch:"
.
$method
.
"-"
.
json_encode
(
$arguments
)
.
'-'
.
print_r
([
$sqlState
,
$errorCode
,
$errorMessage
],
1
));
}
//throw Exception
//throw Exception
// $msg = "mysql error catch:" . $method . "-" . json_encode($arguments) . '-' . json_encode([$sqlState, $errorCode, $errorMessage]);
// $msg = "mysql error catch:" . $method . "-" . json_encode($arguments) . '-' . json_encode([$sqlState, $errorCode, $errorMessage]);
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment