File tree Expand file tree Collapse file tree 1 file changed +17
-1
lines changed
Expand file tree Collapse file tree 1 file changed +17
-1
lines changed Original file line number Diff line number Diff line change 33namespace PFinal \Database ;
44
55use Closure ;
6+ use Pimple \Psr11 \Container ;
67
78/**
89 * 数据库操作辅助类
@@ -21,6 +22,9 @@ class Builder
2122 /** @var static */
2223 protected static $ instance ;
2324
25+ /** @var Container */
26+ protected static $ container ;
27+
2428 /** @var Connection 数据库连接对象 */
2529 private $ db ;
2630
@@ -66,12 +70,24 @@ public function setAsGlobal()
6670 return $ this ;
6771 }
6872
73+ /**
74+ * @param Container $container
75+ */
76+ public static function setContainer ($ container )
77+ {
78+ static ::$ container = $ container ;
79+ }
80+
6981 /**
7082 * @return static
7183 */
7284 public static function getInstance ()
7385 {
74- return static ::$ instance ;
86+ if (static ::$ instance instanceof Builder) {
87+ return static ::$ instance ;
88+ }
89+
90+ return static ::$ container ->get ('PFinal\Database\Builder ' );
7591 }
7692
7793 /**
You can’t perform that action at this time.
0 commit comments