|
@@ -10,7 +10,6 @@
|
|
|
namespace think\db\builder;
|
|
|
|
|
|
use think\db\BaseQuery;
|
|
|
-use think\db\BaseQuery as Query;
|
|
|
use think\db\Builder;
|
|
|
use think\db\Raw;
|
|
|
|
|
@@ -19,9 +18,14 @@ use think\db\Raw;
|
|
|
*/
|
|
|
class Dm extends Builder
|
|
|
{
|
|
|
+ protected $query;
|
|
|
protected $insertAllSql = '%INSERT% INTO %TABLE% (%FIELD%) VALUES %DATA% %COMMENT%';
|
|
|
protected $updateSql = 'UPDATE %TABLE% %JOIN% SET %SET% %WHERE% %ORDER%%LIMIT% %LOCK%%COMMENT%';
|
|
|
|
|
|
+ public function __construct(BaseQuery $query)
|
|
|
+ {
|
|
|
+ $this->query = $query;
|
|
|
+ }
|
|
|
/**
|
|
|
* 生成insertall SQL
|
|
|
* @access public
|
|
@@ -84,7 +88,7 @@ class Dm extends Builder
|
|
|
* @param array $options
|
|
|
* @return string
|
|
|
*/
|
|
|
- public function parseKey(Query $query, string|int|Raw $key, bool $strict = false): string
|
|
|
+ public function parseKey(BaseQuery $query, string|int|Raw $key, bool $strict = false): string
|
|
|
{
|
|
|
if (is_numeric($key)) {
|
|
|
return $key;
|
|
@@ -100,7 +104,7 @@ class Dm extends Builder
|
|
|
} elseif (strpos($key, '.') && !preg_match('/[,\'\"\(\)`\s]/', $key)) {
|
|
|
list($table, $key) = explode('.', $key, 2);
|
|
|
if ('__TABLE__' == $table) {
|
|
|
- $table = $this->query->getTable();
|
|
|
+ $table =$query->getTable();
|
|
|
}
|
|
|
if (isset($options['alias'][$table])) {
|
|
|
$table = $options['alias'][$table];
|
|
@@ -134,12 +138,12 @@ class Dm extends Builder
|
|
|
/**
|
|
|
* Partition 分析.
|
|
|
*
|
|
|
- * @param Query $query 查询对象
|
|
|
+ * @param BaseQuery $query 查询对象
|
|
|
* @param string|array $partition 分区
|
|
|
*
|
|
|
* @return string
|
|
|
*/
|
|
|
- protected function parsePartition(Query $query, $partition): string
|
|
|
+ protected function parsePartition(BaseQuery $query, $partition): string
|
|
|
{
|
|
|
if ('' == $partition) {
|
|
|
return '';
|