search

Home  >  Q&A  >  body text

Error Code: 907 Error Message: ORA-00907: missing closing bracket PHP Laravel (Eloquent Method)

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粉245489391P粉245489391243 days ago399

reply all(1)I'll reply

  • P粉652523980

    P粉6525239802024-03-30 09:39:10

    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', '<', $now)
        ->orderBy('meetings.start_meeting', 'desc')
        ->paginate(5);

    reply
    0
  • Cancelreply