3

I want to use an admin specific page to insert or remove new users, instead of using the Drupal administration panel.

How can I prescind from the Drupal default database and insert the users' information in my personal database? Is it possible?

2 Answers 2

7

In drupal 7 you can easily connect to 2 or more different databases. From your question I guess you have a module to handle the users rather than the normal Drupal Way. So you can follow the following,


$databases = array (
  'default' =>  // main drupal db starts from here
  array (
    'default' => 
    array (
      'database' => 'drupaldb', // main drupal db name
      'username' => 'root', // main drupal db username
      'password' => 'password', // main drupal db password
      'host' => 'localhost',
      'port' => '',
      'driver' => 'mysql',
      'prefix' => '',
    ),
  ),'yourcustomdb' =>  // additional database starts here
  array (
    'default' => 
    array (
      'database' => 'database', // additional database name
      'username' => 'root', // additional database username
      'password' => 'password', // additional database password
      'host' => 'localhost',
      'port' => '',
      'driver' => 'mysql',
      'prefix' => '',
    )
  ),
);

Then in time of calling it,


db_set_active('yourcustomdb');
$query = db_query('....');
db_set_active('default'); // We need to call the main (drupal) db back

I hope this one helps you.

3
  • I thank you for the answer: it is very useful! But I am using the default drupal module: It should be "User". Can you suggest me a module to manage users?
    – andre
    Commented May 16, 2012 at 17:19
  • I guess there is no other modules rather than Users module from Drupal Core. But google can help you I guess. Commented May 16, 2012 at 17:26
  • 1
    One important thing to note about this, is that the databases need to be of the same type for this to work. You can't do this on a mysql/pgsql setup.
    – googletorp
    Commented May 17, 2012 at 11:59
0

Use the Web Services module, it will allow you to make remote calls using a REST server you setup and administer it remotely.

EG: yourdomain.com/rest/user/create

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.