elediamultikeys enrollment plugin - error reading from database

Re: elediamultikeys enrollment plugin - error reading from database

by Robert G -
Number of replies: 0

I was able to fix this error by removing the line: GROUP BY c.id, but now I get a different error... Any thoughts?


Debug info: SQLState: 42000<br>
Error Code: 156<br>
Message: [Microsoft][SQL Server Native Client 11.0][SQL Server]Incorrect syntax near the keyword 'user'.<br>

INSERT INTO mdl_block_eledia_multikeys (course,code,user,mailedto,timecreated) VALUES('2',N'Ja8u6URY9E',NULL,N'email@gmail.com','1406484105')
[array (
0 => '2',
1 => 'Ja8u6URY9E',
2 => NULL,
3 => 'email@gmail.com',
4 => 1406484105,
)]
Error code: dmlwriteexception
Stack trace:
  • line 446 of \lib\dml\moodle_database.php: dml_write_exception thrown
  • line 250 of \lib\dml\sqlsrv_native_moodle_database.php: call to moodle_database->query_end()
  • line 357 of \lib\dml\sqlsrv_native_moodle_database.php: call to sqlsrv_native_moodle_database->query_end()
  • line 919 of \lib\dml\sqlsrv_native_moodle_database.php: call to sqlsrv_native_moodle_database->do_query()
  • line 1000 of \lib\dml\sqlsrv_native_moodle_database.php: call to sqlsrv_native_moodle_database->insert_record_raw()
  • line 151 of \blocks\eledia_multikeys\locallib.php: call to sqlsrv_native_moodle_database->insert_record()
  • line 74 of \blocks\eledia_multikeys\generate_keys.php: call to eledia_multikeys_service->create_keylist()


The code near line 151 looks like:

            $newkeys[] = $newkey;
            $newkeyobj = new stdClass();
            $newkeyobj->course = $courseid;
            $newkeyobj->code = $newkey;
            $newkeyobj->user = null;
            $newkeyobj->mailedto = $mail;
            $newkeyobj->timecreated = time();
            $DB->insert_record('block_eledia_multikeys', $newkeyobj);
        }