Error Code: 907 Error Message: ORA-00907: missing closing bracket PHP Laravel (Eloquent Method)
P粉245489391
P粉245489391 2024-03-29 14:47:52
0
1
461

After getting the collection from the query, I want to sort it. Then, the following error message appears:

Error code: 907 Error message: ORA-00907: Missing right bracket position: 202 Statement: SELECT count(*) FROM EXISTS 'ATTENDANCE_LISTS' AS AGGREGATE (SELECT * FROM 'MEETINGS' WHERE 'ATTENDANCE_LISTS'. "MEETING_ID" = "MEETINGS"."ID" and "STATUS_MEETING" = :p0 and "START_MEETING" <= :p1 order by "START_MEETING" desc) Binding: [Disetujui,2022-04-19 20:11:24 ] (SQL: select count(*) as aggregate in existing "ATTENDANCE_LISTS" (select * from "MEETINGS" where "ATTENDANCE_LISTS"."MEETING_ID" = "MEETINGS"."ID" and "STATUS_MEETING" = Disetujui and "START_MEETING"<= 2022-04 -19 20:11:24 Press "START_MEETING" to order desc))

code show as below:

$meetings2 = AttendanceLists::whereHas('meeting', function ($query) {
    $now = new DateTime("now");
    $query->where('status_meeting', '=', 'Disetujui')
    ->where('start_meeting', '<=', $now)
    ->orderBy('start_meeting', 'desc')
    ;
})->paginate(5);

I just built the query using the Laravel eloquent method above and I've been struggling with this for days. please help me.

Yes, here is a seemingly similar post: ORA-00907: missing closing bracket

However, the problem I am having has nothing to do with manually building the query using SQL format . I built the query using the PHP Laravel eloquent method, so it can't really be an issue about missing brackets. **

edit: In short, the problem arises when I try to sort the attendance list by the "meeting" attribute (sorted by the attribute's attribute). Any help?

P粉245489391
P粉245489391

reply all(1)
P粉652523980

This is the solution.

The solution is to change whereHas to join. code show as below:

$meetings = AttendanceLists::join('meetings', 'meetings.id', '=', 'attendance_lists.meeting_id')
    ->where('attendance_lists.user_id', '=', $id_user)
    ->where('meetings.status_meeting', '=', 'Disetujui')
    ->where('meetings.start_meeting', 'orderBy('meetings.start_meeting', 'desc')
    ->paginate(5);
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template