Updating Records Error :: moodle_database::update_record_raw() no fields found

Updating Records Error :: moodle_database::update_record_raw() no fields found

by Pinki Naskar -
Number of replies: 2
I am getting an error to update course records. I have added one new column to course table and tried to update it through API using a web service client function.


New added column : 

'sis_periodid'=> new external_value(PARAM_INT,'application course period id',VALUE_OPTIONAL)


Used code:

$data2->sis_periodid= 2;

$data2->id=10;

$course1=$DB->update_record('course', $data2); 


Output:

stdClass Object ( [exception] => coding_exception [errorcode] => codingerror [message] => Coding error detected, it must be fixed by a programmer: moodle_database::update_record_raw() no fields found. ) 


Please help me, I have added `sis_periodid` field to course table but getting the above error.




Average of ratings: -
In reply to Pinki Naskar

Re: Updating Records Error :: moodle_database::update_record_raw() no fields found

by Davo Smith -
Picture of Core developers Picture of Particularly helpful Moodlers Picture of Peer reviewers Picture of Plugin developers

Usually a bad idea to add extra fields to core tables, but now that I've given that warning ...

Did you use Moodle upgrade functions to add the extra field ($dbman->add_field($table, $field)) or did you just add it yourself to the database?

If it was the second, then you could try purging the site caches to see if the change is picked up by Moodle.

(Also the return value of 'update_record' is always true - if there is a problem, it throws an exception).

Average of ratings: Useful (1)
In reply to Davo Smith

Re: Updating Records Error :: moodle_database::update_record_raw() no fields found

by Pinki Naskar -
Thanks Davo, after purging caches it works.