我在Laravel 5.3控制器中使用Raw SQL运行脚本,但发现它运行缓慢且不安全(如Raw)。是否有任何方法可以使其更有效并将其转换为雄辩的或Laravel的Query Builder?
代码如下,谢谢!
SELECT machine_code, machine_name
FROM factory_equipment
WHERE machine_code NOT IN
(
SELECT distinct(machine_code)
FROM echecklist_data
WHERE DATE_FORMAT(date, '%Y-%m-%d') = CURDATE()
)
AND type='production' ORDER BY machine_code ASC