Laravel 4 db查询,因为if而导致db :: raw()错误

时间:2015-03-27 05:24:50

标签: php mysql laravel

$data = DB::table('view_term_invoice')
            ->groupby('tenant_no')
            ->select(
                'tenant_no' , 
                DB::raw('count(distinct term_no) as term'),
                DB::raw('count(distinct invoice_no) as invoice_no'),
                //DB::raw("if(type_inv = 'M',count(distinct invoice_no),0) as invoice_m"),
                //DB::raw("if(type_inv = 'T',count(distinct invoice_no),0) as invoice_t"),
                DB::raw("sum(distinct grand_total) as grand_total")
            )
            ->get();

当我在db :: raw上运行此查询时,由于if()内的db::raw而导致错误 当我在phpmyadmin上运行时我没有问题, 我不明白为什么我突然得到这个错误

0 个答案:

没有答案