Using moodle functions to execute SQL Query?