【发布时间】:2016-04-07 08:19:30
【问题描述】:
我正在尝试将这个传统的 sql 查询转换为 larvael/lumen 查询生成器并遇到砖墙。
$query = "SELECT a.id, a.name, a.cuisine, a.status, a.new, a.addressLine1, a.addressLine2, a.addressLine3, a.city, a.weekendot, a.weekendct, b.class
FROM restaurants a, restaurants_class b
WHERE a.class = b.id
AND '$date' = CURRENT_DATE
AND '$ntime' BETWEEN a.weekendot AND a.weekendct
ORDER BY id DESC";
$date 和 $ntime 是变量。
这是我目前所拥有的;
$posts = DB::connection('web')
->table('restaurants')
->join('restaurants_class', 'restaurants.class', '=', 'restaurants_class.id')
->select('restaurants.*', 'restaurants_class.*')
->get();
第一个AND 语句没有从DB 得到任何东西
第二个AND 语句将var 与DB 中的两列进行比较
不确定如何实现whereBetween
【问题讨论】:
标签: php mysql laravel laravel-5 lumen