As with everything this started as a simple addition to my theme, in fact I fully intended to recycle code form a block I developed some time ago but ended up with me banging my head against a wall all evening. I keep getting:
Call to a member function get_records_sql() on null
when I try to use $DB within a theme layout file.
The code Im trying works just fine from within a block, is it the context thats messing me up?
global $DB, $OUTPUT, $USER;
and in case it is of any interest, the function:
$modulecompletions = $DB->get_records_sql('SELECT * FROM mdl_course_modules_completion WHERE userid = ?', array($user_id));