I'm not sure if this is possible. I am trying to improve a BI Dashboard plugin I have made, trying to minimise the amount of processing power and DB calls it makes.
Currently to get the activity instance record I do this
$sql = "SELECT cm.id, cm.instance, m.name
FROM {course_modules} cm
INNER JOIN {modules} m ON m.id = cm.module
WHERE m.name <> 'label' AND cm.id IN (".$course_activities.")"; $course_modules = $DB->get_records_sql($sql, null); foreach ($course_modules as $cmkey => $course_module) { $activity_instance = $DB->get_record($course_module->name, array('id'=>$course_module->instance)); ..... ..... }
Is there a way that I can include the activity instance in the first query. ie.
Something like:
$sql = "SELECT cm.id, cm.instance, m.name, a.name
FROM {course_modules} cm
INNER JOIN {modules} m ON m.id = cm.module
INNER JOIN {m.name} a ON a.id = cm.instance
WHERE m.name <> 'label' AND cm.id IN (".$course_activities.")";