改名
This commit is contained in:
@@ -294,8 +294,7 @@ class SqlBuilder extends Component
|
|||||||
public function tableName(): string
|
public function tableName(): string
|
||||||
{
|
{
|
||||||
if ($this->query->from instanceof \Closure) {
|
if ($this->query->from instanceof \Closure) {
|
||||||
call_user_func($this->query->from, $activeQuery = new Sql());
|
$this->query->from = '(' . $this->query->makeClosureFunction($this->query->from) . ')';
|
||||||
$this->query->from = '(' . $activeQuery->getSql() . ')';
|
|
||||||
}
|
}
|
||||||
if ($this->query->from instanceof ActiveQuery) {
|
if ($this->query->from instanceof ActiveQuery) {
|
||||||
$this->query->from = '(' . SqlBuilder::builder($this->query->from)->get($this->query->from) . ')';
|
$this->query->from = '(' . SqlBuilder::builder($this->query->from)->get($this->query->from) . ')';
|
||||||
|
|||||||
@@ -813,7 +813,7 @@ trait QueryTrait
|
|||||||
public function where(callable|array|string $conditions): static
|
public function where(callable|array|string $conditions): static
|
||||||
{
|
{
|
||||||
if ($conditions instanceof Closure) {
|
if ($conditions instanceof Closure) {
|
||||||
$conditions = '(' . $this->makeClosureFunction($conditions) . ')';
|
$conditions = $this->makeClosureFunction($conditions);
|
||||||
}
|
}
|
||||||
$this->where[] = $conditions;
|
$this->where[] = $conditions;
|
||||||
return $this;
|
return $this;
|
||||||
@@ -828,7 +828,7 @@ trait QueryTrait
|
|||||||
* @throws ReflectionException
|
* @throws ReflectionException
|
||||||
* @throws Exception
|
* @throws Exception
|
||||||
*/
|
*/
|
||||||
private function makeClosureFunction(Closure|array $closure, $onlyWhere = false): string
|
public function makeClosureFunction(Closure|array $closure, $onlyWhere = false): string
|
||||||
{
|
{
|
||||||
$generate = $this->makeNewSqlGenerate();
|
$generate = $this->makeNewSqlGenerate();
|
||||||
if ($closure instanceof Closure) {
|
if ($closure instanceof Closure) {
|
||||||
@@ -839,7 +839,7 @@ trait QueryTrait
|
|||||||
if ($onlyWhere === true) {
|
if ($onlyWhere === true) {
|
||||||
return $generate->getCondition();
|
return $generate->getCondition();
|
||||||
}
|
}
|
||||||
return $generate->getSql();
|
return '(' . $generate->getSql() . ')';
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user