Hi there everyone,
I tried to find the cause of my issue. If I comment on this "#OR e.enrol = 'guest'" condition from the query then the result will come. May I know the actual reason? Did I miss any configuration in moodle?
SELECT c.id,idnumber,summary,summaryformat,startdate,enddate,category,shortname,fullname,timeaccess,component, ctx.id AS ctxid, ctx.path AS ctxpath, ctx.depth AS ctxdepth, ctx.contextlevel AS ctxlevel, ctx.instanceid AS ctxinstance, ctx.locked AS ctxlocked
FROM mdl_course c
JOIN mdl_context ctx
ON ctx.contextlevel = 50
AND ctx.instanceid = c.id
JOIN mdl_user_lastaccess ul
ON ul.courseid = c.id
LEFT JOIN mdl_favourite fav
ON fav.component = 'core_course'
AND fav.itemtype = 'courses'
AND fav.userid = 14401
AND fav.itemid = ul.courseid
WHERE ul.userid = 14401
AND c.visible = 1
AND EXISTS (SELECT e.id
FROM mdl_enrol e
LEFT JOIN mdl_user_enrolments ue ON ue.enrolid = e.id
WHERE e.courseid = c.id
AND e.status = 0
AND ((ue.status = 0
AND ue.userid = ul.userid
AND ue.timestart < 1590494500
AND (ue.timeend = 0 OR ue.timeend > 1590494500)
)
#OR e.enrol = 'guest'
)
)
ORDER BY timeaccess DESC
Please check the above query. If I comment this ``OR e.enrol = 'guest'`` then it is working. why is this condition creating a problem for me?
I tried to find the cause of my issue. If I comment on this "#OR e.enrol = 'guest'" condition from the query then the result will come. May I know the actual reason? Did I miss any configuration in moodle?
SELECT c.id,idnumber,summary,summaryformat,startdate,enddate,category,shortname,fullname,timeaccess,component, ctx.id AS ctxid, ctx.path AS ctxpath, ctx.depth AS ctxdepth, ctx.contextlevel AS ctxlevel, ctx.instanceid AS ctxinstance, ctx.locked AS ctxlocked
FROM mdl_course c
JOIN mdl_context ctx
ON ctx.contextlevel = 50
AND ctx.instanceid = c.id
JOIN mdl_user_lastaccess ul
ON ul.courseid = c.id
LEFT JOIN mdl_favourite fav
ON fav.component = 'core_course'
AND fav.itemtype = 'courses'
AND fav.userid = 14401
AND fav.itemid = ul.courseid
WHERE ul.userid = 14401
AND c.visible = 1
AND EXISTS (SELECT e.id
FROM mdl_enrol e
LEFT JOIN mdl_user_enrolments ue ON ue.enrolid = e.id
WHERE e.courseid = c.id
AND e.status = 0
AND ((ue.status = 0
AND ue.userid = ul.userid
AND ue.timestart < 1590494500
AND (ue.timeend = 0 OR ue.timeend > 1590494500)
)
#OR e.enrol = 'guest'
)
)
ORDER BY timeaccess DESC
Please check the above query. If I comment this ``OR e.enrol = 'guest'`` then it is working. why is this condition creating a problem for me?