Hello I use moodle 3.2 with mysql database.
I am trying to create a new plugin that record files on moodledata and correpondingly inserts data about this files in the database.
I am using a filepicker, upload a zip file, and then the plugin unzip the files to the moodledata structure.
It is working fine but the function that unzip the files (extract_to_storage) , also record their information in the database. The function return no error, it returns the id of the records inserted in the database but when I look for the informations on database there is nothing there.
Ultimately extract_to_storage uses $DB->insert_record to record the info on the database. Insert_record calls insert_record_raw.
I used the following lines wrapping the insert commands of insert_record_raw (before):
$this->mysqli->autocommit(FALSE);
$this->mysqli->query( "START TRANSACTION" );
and (after):
$this->mysqli->commit();
And now the information are being recorded correctly in the database.
But it does not make sense. Others functions that use insert_record_raw without that new lines I provided use to work fine saving records on database.
I am missing something?
What should I do to proper insert the file data in the database?
Thanks in advance.