Databases: problem in adding table

Databases: problem in adding table

by Marigianna Skouradaki -
Number of replies: 1

hello, i am trying to create a new table in DB. However im not developing a new plugin. I just need it for changes on the moodle core. It seems like i have successfully added the table through XMLDB (and then added the relevan php code in upgrade.php) however when i am trying to insert date through code i get errors that it cannot find the table.

Table is created in lib.php

Code in \question\type\questiontype.php is:

$ediammeRecord = new stdClass();

$ediammeRecord->type= 'question';

$ediammeRecord->tags= '';

$ediammeRecord->referenceId = $question->id;

$ediammeRecord->id = $DB->insert_record('ediamme_search',$ediammeRecord);

the error i get :

Debug info:

Table 'moodle.mdl_ediamme_search' doesn't exist SHOW COLUMNS FROM mdl_ediamme_search [NULL]

Stack trace: line 391 of /lib/dml/moodle_database.php: dml_read_exception thrown

line 438 of /lib/dml/mysqli_native_moodle_database.php: call to moodle_database->query_end()

line 906 of /lib/dml/mysqli_native_moodle_database.php: call to mysqli_native_moodle_database->get_columns()

line 369 of /question/type/questiontype.php: call to mysqli_native_moodle_database->insert_record()

line 251 of /question/question.php: call to default_questiontype->save_question()

Average of ratings: -
In reply to Marigianna Skouradaki

Re: Databases: problem in adding table

by Marcus Caba -

 

wild guess: mdl_ediamma_search doesnt exist, but ediamma_search does?

Be aware that insert_record appends a prefix to table names as defined in $CFG (usually 'mdl_').