lgy преди 1 месец
родител
ревизия
d10d58d9c1
променени са 2 файла, в които са добавени 27 реда и са изтрити 1 реда
  1. 0 1
      jcjyhr/vendor/topthink/think-orm/src/db/BaseQuery.php
  2. 27 0
      jcjyhr/vendor/topthink/think-orm/src/db/builder/Dm.php

+ 0 - 1
jcjyhr/vendor/topthink/think-orm/src/db/BaseQuery.php

@@ -1314,7 +1314,6 @@ abstract class BaseQuery
      */
     public function select(array $data = []): Collection
     {
-        var_dump(1);die;
         if (!empty($data)) {
             // 主键条件分析
             $this->parsePkWhere($data);

+ 27 - 0
jcjyhr/vendor/topthink/think-orm/src/db/builder/Dm.php

@@ -11,6 +11,7 @@ namespace think\db\builder;
 
 use think\db\BaseQuery;
 use think\db\BaseQuery as Query;
+use think\db\BaseQuery as Query;
 use think\db\Builder;
 use think\db\Raw;
 
@@ -22,6 +23,32 @@ class Dm extends Builder
     protected $insertAllSql = '%INSERT% INTO %TABLE% (%FIELD%) VALUES %DATA% %COMMENT%';
     protected $updateSql    = 'UPDATE %TABLE% %JOIN% SET %SET% %WHERE% %ORDER%%LIMIT% %LOCK%%COMMENT%';
 
+    public function select(Query $query, bool $one = false): string
+    {
+        $options = $query->getOptions();
+
+        return str_replace(
+            ['%TABLE%', '%PARTITION%', '%DISTINCT%', '%EXTRA%', '%FIELD%', '%JOIN%', '%WHERE%', '%GROUP%', '%HAVING%', '%ORDER%', '%LIMIT%', '%UNION%', '%LOCK%', '%COMMENT%', '%FORCE%'],
+            [
+                $this->parseTable($query, $options['table']),
+                $this->parsePartition($query, $options['partition']),
+                $this->parseDistinct($query, $options['distinct']),
+                $this->parseExtra($query, $options['extra']),
+                $this->parseField($query, $options['field'] ?? []),
+                $this->parseJoin($query, $options['join']),
+                $this->parseWhere($query, $options['where']),
+                $this->parseGroup($query, $options['group']),
+                $this->parseHaving($query, $options['having']),
+                $this->parseOrder($query, $options['order']),
+                $this->parseLimit($query, $one ? '1' : $options['limit']),
+                $this->parseUnion($query, $options['union']),
+                $this->parseLock($query, $options['lock']),
+                $this->parseComment($query, $options['comment']),
+                $this->parseForce($query, $options['force']),
+            ],
+            $this->selectSql
+        );
+    }
     /**
      * 生成insertall SQL
      * @access public