I have been getting up to speed on how Drupal works with its own database to control its functionality, but I also need my pages to pull data from my own databases. I've found documentation on Drupal's database functions and on working with multiple databases, but I haven't found a tutorial or sample code for how to implement all that in a Drupal page.

To make tables based on data pulled from my own databases, should I:

If I just need a single data value from my database, do I do that just with a PHP snippet that calls "db_query()"?

Is there a tutorial or sample code for how to use non-Drupal data as content for a Drupal page? (There is brief mention of the idea in the Site Building Guide in Data module: managing foreign database tables and How Data relates to Table Wizard, but it doesn't say much.)

Thanks for your help.

Comments

NewSites’s picture

Could somebody share some wisdom on this please? I've finally got multi-site functionality working (phew!!) and I'm ready to start adding content. I'd like to do it the right way, so your suggestions will be appreciated.

nevets’s picture

Please do not cross post your questions, I removed the duplicate.

As for why not answers, your question is both complex and not a topic many people deal with.

The answer in part lies in the answers to Why do you need to pull data from your own databases?, Does the data need to stay in those tables?

In general working with foreign data is effort since by default it does not tie in the Drupal system. My preferences are if the data can be pulled into Drupal without the need for periodic updates would be to use migrate, if you need to periodically update the data I would consider feeds.

NewSites’s picture

I've found what I think is the answer to the part of my question about how to import the data, and I've turned that answer into my first contribution to the Drupal documentation: Import data from Access to MySQL for Drupal content (not CMS data) in the Site Building Guide. That answer, of course, is specific to my particular source data, which is in Access.

I'm open to feedback on whether that is the best method. I'm also still interested in answers to the other part of my question, which is how best to now use that imported data to build the site content.

Thanks.