Skip to content

Commit 1c5849f

Browse files
committed
改进数据库事件
1 parent 6ff393a commit 1c5849f

File tree

1 file changed

+6
-7
lines changed

1 file changed

+6
-7
lines changed

src/connector/Mongo.php

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -35,17 +35,14 @@
3535
*/
3636
class Mongo
3737
{
38-
protected static $instance = [];
39-
protected $dbName = ''; // dbName
38+
protected $dbName = ''; // dbName
4039
/** @var string 当前SQL指令 */
4140
protected $queryStr = '';
4241
// 查询数据类型
4342
protected $typeMap = 'array';
4443
protected $mongo; // MongoDb Object
4544
protected $cursor; // MongoCursor Object
4645

47-
// 监听回调
48-
protected static $event = [];
4946
/** @var Manager[] 数据库连接ID 支持多个连接 */
5047
protected $links = [];
5148
/** @var Manger 当前连接ID */
@@ -560,10 +557,12 @@ public function getLastSql(): string
560557
*/
561558
protected function triggerSql(string $sql, string $runtime, array $options = [], bool $master = false): void
562559
{
563-
if (!empty(self::$event)) {
564-
foreach (self::$event as $callback) {
560+
$listen = $this->db->getListen();
561+
562+
if (!empty($listen)) {
563+
foreach ($listen as $callback) {
565564
if (is_callable($callback)) {
566-
call_user_func_array($callback, [$sql, $runtime, $options, $master]);
565+
$callback($sql, $runtime, $options, $master);
567566
}
568567
}
569568
} else {

0 commit comments

Comments
 (0)