User::where('theme_code', 'gw')->where(function ($query) { $query->where("status", 0)->orwhere([["entry_time", ">=", time()], ["resignation_time", "=<", time()]]); }) ->whereHasIn("adviser", function ($query) { $query->where("lft", ">=",1)->where("rgt","<=",2); })->first()打印出sql语句
时间: 2023-07-19 14:29:31 浏览: 123
您可以使用以下代码来打印出执行的 SQL 语句:
```php
$query = User::where('theme_code', 'gw')
->where(function ($query) {
$query->where("status", 0)
->orWhere([["entry_time", ">=", time()], ["resignation_time", "=<", time()]]);
})
->whereHasIn("adviser", function ($query) {
$query->where("lft", ">=", 1)->where("rgt", "<=", 2);
});
dd($query->toSql());
```
请注意,此代码仅返回查询语句的字符串表示形式,而不实际执行查询。如果您需要执行查询并获取结果,请使用`get()`或`first()`方法。
阅读全文