File tree Expand file tree Collapse file tree 1 file changed +8
-1
lines changed Expand file tree Collapse file tree 1 file changed +8
-1
lines changed Original file line number Diff line number Diff line change @@ -87,6 +87,12 @@ class ShardingQuery
8787 */
8888 protected $ trace ;
8989
90+ /**
91+ * 表通配符
92+ * @var string
93+ */
94+ protected static $ tableSymbol = '{table} ' ;
95+
9096 /**
9197 * ShardingQuery constructor.
9298 * @param array $config
@@ -176,7 +182,7 @@ public function select()
176182 $ sql = $ this ->sql ();
177183 $ data = [];
178184 foreach ($ range as $ tableName => $ item ) {
179- $ tmpSql = str_replace (' {table} ' , $ tableName , $ sql );
185+ $ tmpSql = str_replace (static :: $ tableSymbol , $ tableName , $ sql );
180186 $ tmpSql = "{$ tmpSql } LIMIT {$ item ['limit ' ]} OFFSET {$ item ['offset ' ]}" ;
181187 $ result = call_user_func ($ this ->callback , $ tmpSql );
182188 $ data = array_merge ($ data , $ result );
@@ -202,6 +208,7 @@ protected function stats($table)
202208 if (!empty ($ this ->where )) {
203209 $ sql .= " WHERE {$ this ->where }" ;
204210 }
211+ $ sql = str_replace (static ::$ tableSymbol , $ tableName , $ sql );
205212 $ result = call_user_func ($ this ->callback , $ sql );
206213 $ first = array_pop ($ result );
207214 $ count = array_pop ($ first );
You can’t perform that action at this time.
0 commit comments