jeudi 20 décembre 2018

laravel something went wrong in query or left join

There is two tables Attendance and Break. In Attendance table there are two column start_time and end_time and these column start_break_time and end_break_time are in break table. also admin can change/modify any of time from attendance/break, I am cloning previous records into Attendance_Log and Break_Log table before edited.

I am using left join in AttendanceModel which is working fine when viewing current Attendance record which is came form Attendance and Break table, Also I have also added following condition for Current/Log Attendance

    if($url_seg_four =='log'){
        $attendance_table = 'Attendance_Log';
        $break_table = 'Break_Log';
    } else {
        $attendance_table = 'Attendance';
        $break_table = 'Break';
    }

    DB::table($attendance_table)->select('attendance.*',
        DB::raw('GROUP_CONCAT(CONCAT(start_break_time,'"-"',end_break_time)) as break_punch_records') ,
    )
    ->leftJoin($break_table,'attendance.id','=','break.attendance_id')
    ->get()

but the problem is that break_punch_records column null when I am viewing Log of same attendance and surprising thing is that when I get last query of Log Attendance and run it on mysql tool break_punch_records is showing with records value.

Note: I am also confused where that bug occur if there is error in query of log how records are correctly showing with break_punch_records and if its error from laravel/php then how records are correctly showing in current attendance view.



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire