1

I have developed website using Drupal. I have created an application without using Drupal, using another framework. In my application I also stored site logo,site name etc. I want to update my site information table when updating Drupal site information from admin/settings/site-information.

The fields are the following ones:

  • id: int(12), primary key

  • site_title: varchar(60)

  • site_logo: varchar(200)

0

There are many ways to do this, but I guess one simple and 'drupalish' way to do this:

Define multiple databases in your drupal instance

Set your 2 databases to be available to drupal.

Then, it is just a matter of deciding when you want to fetch and update the data.

You could use hook_install (or hook_enable) and add a query in there that would load your data in drupal database when enabling the module. Or, you could create a callback that would update the data when you visit a certain url, all of this is up to you.

Hope this helps, good-luck.

| improve this answer | |
  • Thanks, glad this helped you. Not that it changes much, but you are allowed to upvote the accepted answer. :) – stefgosselin Dec 16 '11 at 10:33
1

You can use a hook_form_alter to add a submit function to the form, see http://drupal.org/node/222158 (for D6 but should be the same for D7).

In your new submit function you can do whatever you want...

You can query other database following this doc http://drupal.org/node/18429

  $other_database = array(
      'database' => 'databasename',
      'username' => 'username', // assuming this is necessary
      'password' => 'password', // assuming this is necessary
      'host' => 'localhost', // assumes localhost
      'driver' => 'mysql', // replace with your database driver
  );
  // replace 'YourDatabaseKey' with something that's unique to your module
  Database::addConnectionInfo('YourDatabaseKey', 'default', $other_database);
  db_set_active('YourDatabaseKey');

  // execute queries here

  db_set_active(); // without the paramater means set back to the default for the site
  drupal_set_message(t('The queries have been made.'));
| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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