SQLSTATE[42804]: Datatype mismatch: 7 ERROR: argument of AND must be type boolean, not type integer LINE 1: ... FROM user_events u WHERE (u.event_id = 24805 AND u.user_id ... ^