mardi 11 juillet 2017

Laravel DB query group by output is different

I have the following implemented query in my Laravel project, the query is working if I copy paste in the console, but the DB object sets on subquery group by zeit_von to group by zeit_von is null

$data = DB::table('epx_supply AS s')
            ->select(
                    DB::raw('count(s.employee) as anzahl_employee'),
                    DB::raw('group_concat(a.account_lastname order by a.account_lastname ) AS employee_names'),
                    DB::raw('date_format(s.zeit_von, "%Y") as y'),
                    DB::raw('date_format(s.zeit_von, "%m") as m'),
                    DB::raw('date_format(s.zeit_von, "%d") as d'),
                    DB::raw('date_format(s.zeit_von, "%h") as h')
            )
            ->leftJoin('phpgw_accounts AS a', 'a.account_id', '=', 's.employee')
            ->where('deleted', 0)
            ->whereIn('supply_status', [1,3])
            ->where(
                DB::raw('( select count(cal_id) from phpgw_cal_utf8  as c
                        where c.owner=s.employee
                        and deleted=0
                        and date_format(s.zeit_von, "%d.%m.%y")=date_format(from_unixtime(c.mdatetime), "%d.%m.%y")
                        and c.category="Krank"
                    )<1 and date_format((s.zeit_von), "%Y")="'.$year.'" group by zeit_von'
               )
            )
            ->get();

What i'm missing in this case?



from Newest questions tagged laravel-5 - Stack Overflow http://ift.tt/2udBcMp
via IFTTT

Aucun commentaire:

Enregistrer un commentaire