Skip to content

Commit 2f66155

Browse files
committed
fixed QueryExecListener
1 parent cecb207 commit 2f66155

File tree

1 file changed

+15
-7
lines changed

1 file changed

+15
-7
lines changed

src/Listener/QueryExecListener.php

Lines changed: 15 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,17 @@
22

33
declare(strict_types=1);
44
/**
5-
* 本文件属于KK馆版权所有,泄漏必究。
6-
* This file belong to KKGUAN, all rights reserved.
5+
* This file is part of project hyperf-soar.
6+
*
7+
* @author wenber.yu@creative-life.club
8+
* @link https://github.com/wilbur-yu
9+
*
10+
* @link https://www.hyperf.io
11+
* @document https://hyperf.wiki
12+
* @contact group@hyperf.io
13+
* @license https://github.com/hyperf/hyperf/blob/master/LICENSE
714
*/
15+
816
namespace Wilbur\HyperfSoar\Listener;
917

1018
use Hyperf\Contract\ConfigInterface;
@@ -15,12 +23,12 @@
1523
use Hyperf\Utils\Context;
1624
use Hyperf\Utils\Str;
1725

26+
1827
#[Listener]
1928
class QueryExecListener implements ListenerInterface
2029
{
21-
public const SQL_RECORD_KEY = 'wilbur-yu-hyperf-soar-sql-listener';
22-
2330
protected bool $soarIsEnabled;
31+
public const SQL_RECORD_KEY = 'wilbur-yu-hyperf-soar-sql-listener';
2432

2533
public function __construct(ConfigInterface $config)
2634
{
@@ -38,12 +46,12 @@ public function process(object $event): void
3846
{
3947
if ($event instanceof QueryExecuted && $this->soarIsEnabled) {
4048
$sql = str_replace('`', '', $event->sql);
41-
if (! Arr::isAssoc($event->bindings)) {
49+
if (!Arr::isAssoc($event->bindings)) {
4250
foreach ($event->bindings as $value) {
43-
$sql = Str::replaceFirst('?', "'{$value}'", $sql);
51+
$sql = Str::replaceFirst('?', "'$value'", $sql);
4452
}
4553
}
46-
$eventSqlList = (array) Context::get(self::SQL_RECORD_KEY);
54+
$eventSqlList = (array)Context::get(self::SQL_RECORD_KEY);
4755
$eventSqlList[] = $sql;
4856
Context::set(self::SQL_RECORD_KEY, $eventSqlList);
4957
}

0 commit comments

Comments
 (0)