Laravel响应返回空,但是当我在db中打印并运行查询时

时间:2019-05-29 15:38:44

标签: php mysql laravel-5

这是我正在使用的查询代码,请查看并帮助我。我真的很感激

DB::table('position as p') -> addSelect(\DB::raw(
        'p.*,(SELECT name from user where user.id=p.user_id) as name'
    )) 
    -> addSelect(\DB::raw(
        'DATE_FORMAT(p.created_at,"%H:%i") as time'
    ))
    -> whereRaw($wr) 
    -> whereRaw(
        "(p.id =(SELECT id FROM position WHERE position.user_id=p.user_id AND Date(position.created_at)='".$date.
        "' order by position.id asc limit 0,1) Or p.id =(SELECT id FROM position WHERE position.user_id=p.user_id AND Date(position.created_at)='".$date.
        "' order by position.id desc limit 0,1))") 
    -> orderBy("p.user_id", "asc") - > orderBy("p.id", 'asc') - > get();

0 个答案:

没有答案