thinkphp5 多表查询条件 or 和and 查询匿名函数
2022/3/21 17:29:43
本文主要是介绍thinkphp5 多表查询条件 or 和and 查询匿名函数,对大家解决编程问题具有一定的参考价值,需要的程序猿们随着小编来一起学习吧!
需要这样的sql效果
SELECT `a`.*,`user_name`,`dept_id` FROM `studentwork_leave` `a` LEFT JOIN `users` `u` ON `a`.`stu_id`=`u`.`user_id` WHERE ( ( `time_start` BETWEEN '2022-03-20 08:35' AND '2022-03-21 22:35' OR `time_end` BETWEEN '2022-03-20 08:35' AND '2022-03-21 22:35' ) OR ( (UNIX_TIMESTAMP(time_start)<=1647736500 AND UNIX_TIMESTAMP(time_end)>=1647873300) ) )
查询请假的数据 时间有穿插的问题
$model = model('Studentleave');
$model->where('handle_status', 'lt', 2);
time_start 开始请假时间筛选
$model->where(function ($query) use ($data) { $query->whereOr("time_start|time_end","between", [$data['time_start'],$data['time_end']]); $query->whereor('(UNIX_TIMESTAMP(time_start)<=' . strtotime($data['time_start']) . ' AND UNIX_TIMESTAMP(time_end)>=' . strtotime($data['time_end']) . ')'); });
这篇关于thinkphp5 多表查询条件 or 和and 查询匿名函数的文章就介绍到这儿,希望我们推荐的文章对大家有所帮助,也希望大家多多支持为之网!
- 2024-03-29env: php: no such file or directory
- 2024-03-01php foreach break
- 2024-02-26Exception参数 php-icode9专业技术文章分享
- 2023-12-30PHP文件批量上传-icode9专业技术文章分享
- 2023-12-30thinkphp6 withJoin-icode9专业技术文章分享
- 2023-12-27MagicArray:像php一样,让Go业务代码不再卷!
- 2023-11-18centos7编译安装PHP教程。
- 2023-11-18centos7编译安装phpMyAdmin教程。
- 2023-10-13唱衰这么多年,PHP 仍然还是你大爷!
- 2023-07-25PHP8,性能更好,语法更好,类型安全更完善