改名
This commit is contained in:
+10
-1
@@ -254,7 +254,16 @@ class SqlBuilder extends Component
|
|||||||
*/
|
*/
|
||||||
public function tableName(): string
|
public function tableName(): string
|
||||||
{
|
{
|
||||||
return $this->query->modelClass::getTable();
|
if ($this->query->from instanceof \Closure) {
|
||||||
|
$this->query->from = call_user_func($this->query->from, new ActiveQuery($this->query->modelClass));
|
||||||
|
}
|
||||||
|
if ($this->query->from instanceof ActiveQuery) {
|
||||||
|
$this->query->from = '(' . SqlBuilder::builder($this->query->from)->get($this->query->from) . ')';
|
||||||
|
}
|
||||||
|
if (empty($this->query->from)) {
|
||||||
|
return $this->query->modelClass::getTable();
|
||||||
|
}
|
||||||
|
return $this->query->from;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -28,7 +28,7 @@ trait QueryTrait
|
|||||||
public ?int $offset = NULL;
|
public ?int $offset = NULL;
|
||||||
public ?int $limit = NULL;
|
public ?int $limit = NULL;
|
||||||
public string $group = '';
|
public string $group = '';
|
||||||
public string $from = '';
|
public string|\Closure|ActiveQuery $from = '';
|
||||||
public string $alias = 't1';
|
public string $alias = 't1';
|
||||||
public array $filter = [];
|
public array $filter = [];
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user