I have a task where I have to update table row (duedate). Table name is mdl_competency_plan.
I am implementing a scheduled task which will run automatically and update user competency plan "duedate" row.
I have "userid" and "name" of the row to be updated.
Below is my code.It is not updating the row.
$DATA = $DB->get_recordset_sql ("Select userid,name,duedate from vw_duedate_autosetuser");
$setduedate= strtotime('duedate');
$DB->execute("UPDATE {competency_plan} SET duedate= '{$setduedate}' WHERE userid = '{$userid}' AND name= '{$name}'");
var_dump gives me below record.
array(3) {
["userid"]=>
string(4) "3966"
["name"]=>
string(15) "Learning Plan 1"
["duedate"]=>
string(19) "2019-04-14 07:15:10"
}