LMSouq
moodle-core Open

Moodle update mysql from code

US
user1882752
1 month ago
3 views
Problem Description
I am unfamiliar with Moodles methods of updating a database with code. I have this statement: $expiredCourseArchiveIntegritaxSql = "UPDATE mdl_course SET category = 29 WHERE expireDate < '" . $date . "' AND category = 28"; $expiredCourseIntegritaxArchive = $DB->get_records_sql($expiredCourseArchiveIntegritaxSql); This format works when getting records from a DB but not updating. I cannot find an example of how to updated the db using Moodles $DB functions. I assume the iussue is that I am using: $DB->get_records_sql($expiredCourseArchiveIntegritaxSql); When the syntax should be somthing more like: $DB->update_records_sql($expiredCourseArchiveIntegritaxSql);

AI-Generated Solution

Powered by LMSouq AI · GPT-4.1-mini

✓ Solution Ready
Analyzing problem and generating solution…
Was this solution helpful?
Back to Knowledge Base