Laravel UNION ALL 不适用于 where 语句
Laravel UNION ALL not working with where statement
我想把两个队列合二为一。
$buildings_queue=IngameBuildingQueue::where(DB::raw('UNIX_TIMESTAMP(`start_time` + `duration`)'),'<=',time());
$recruit_queue=IngameRecruitQueue::where(DB::raw('UNIX_TIMESTAMP(`start_time` + `duration`)'),'<=',time());
$queue=$buildings_queue->unionAll($recruit_queue);
dd($queue->toSql());
Laravel 抛出:
[ErrorException] Undefined property: Illuminate\Database\Eloquent\Builder::$bindings
但是当我删除 where()
方法时一切正常。
我该如何解决?
根据 Laravel 用户手册,这应该有效
IngameRecruitQueue::where(DB::raw('UNIX_TIMESTAMP(`start_time` + `duration`)'),'<=',time())->union($buildings_queue)->get();
也尝试用驼峰命名法编写你的变量
$buildings_queue 将是 $buildingsQueue
查看此答案以了解更多信息:https://softwareengineering.stackexchange.com/a/196463
我想把两个队列合二为一。
$buildings_queue=IngameBuildingQueue::where(DB::raw('UNIX_TIMESTAMP(`start_time` + `duration`)'),'<=',time());
$recruit_queue=IngameRecruitQueue::where(DB::raw('UNIX_TIMESTAMP(`start_time` + `duration`)'),'<=',time());
$queue=$buildings_queue->unionAll($recruit_queue);
dd($queue->toSql());
Laravel 抛出:
[ErrorException] Undefined property: Illuminate\Database\Eloquent\Builder::$bindings
但是当我删除 where()
方法时一切正常。
我该如何解决?
根据 Laravel 用户手册,这应该有效
IngameRecruitQueue::where(DB::raw('UNIX_TIMESTAMP(`start_time` + `duration`)'),'<=',time())->union($buildings_queue)->get();
也尝试用驼峰命名法编写你的变量
$buildings_queue 将是 $buildingsQueue
查看此答案以了解更多信息:https://softwareengineering.stackexchange.com/a/196463