Hello everyone! I am sorry about my bad English, but I have a question.
So, I had build a site for some college where the children take an exams, before start to learn. I did it with QUIZ module that works very nice! And now I need that the result of the quiz (exam) will send the data to external database. For today, the data saved in drupal database table...

How can I do that?

thank you

Comments

nicolicioiu.liviu’s picture

In settings.php, add new connection:

$db_url = array(
'default'=>'mysqli://user1:pass1@host1/drupal_1',
//the game table
'extern' =>'mysqli://user1:pass1@host2/extern',
);

Create and use function:
function _extern_db_query(){
db_set_active(variable_get('extern_database', 'extern'));
$args = func_get_args();
$result = call_user_func_array('db_query', $args);
db_set_active();
return $result;
}

External database must be up all the time, if not, then the website will be offline.