drupalからmoodleデータベースに行を挿入していて、最後に挿入された行のIDを取得したいのですが、私はどこにも行きません。 ここに私のコードです。drupalでmysql_insert_id()を呼び出さない
$moodle_database = array(
'database' => 'moood',
'username' => 'root',
'password' => '',
'host' => 'localhost', //52.23.83.176
'driver' => 'mysql',
);
Database::addConnectionInfo('moodle_db', 'default', $moodle_database);
db_set_active('moodle_db');
try {
$question_query ="INSERT INTO mdl_question ".
"(category,parent,name,questiontext,generalfeedback) ".
"VALUES ".
"('$category','$parent','$name','$questiontext','$generalfeedback')";
$queryResult=db_query($question_query);
$id = mysql_insert_id($queryResult);
}
catch (Exception $e) {
drupal_set_message(t('Exception while fetching question data ' . $e->getMessage()));
}
db_set_active();
このURL「https:// www.drupal.org/node/151718」にアクセスしてください。 –