I need to write to a database table from inside a cron job.
I have some code that looks like this:
$ins = new stdClass();
$ins->Success = $message;
$ins->Email = $Email;
$ins->CompleteData = $theCompleteDate;
$ins->Hours = $theHours;
$ins->TrainingType = $theTrainingType;
global $DB;
$ins->id = $DB->insert_record('imis_log', $ins);
The last line throws an error, presumable because $DB is not known in a cron task.
How do I fix this?
Thanks.