<br><br><br><br><div class="gmail_quote">On Thu, Nov 19, 2009 at 8:34 AM, <a href="mailto:larry@garfieldtech.com">larry@garfieldtech.com</a> <span dir="ltr"><<a href="mailto:larry@garfieldtech.com">larry@garfieldtech.com</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;"><div class="im">spartaguy spartaguy wrote:<br>
<blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
<br>
Thanks to everyone that replied.<br>
<br>
<br>
To summarise then:<br>
<br>
1) I need to make a custom module.<br>
2) The module should have a block for displaying the query and a menu hook<br>
3) I can add the module to either primary links or navigation as a menu item<br>
4) Rendered HTML using mysql commands is quite straight forward<br>
5) The tables being queried are easier to access within the main drupal d/b but i can use a different db<br>
<br>
Regarding a different db, does this command:<br>
<br>
db_set_active('customerdb');<br>
<br>
make *all* db queries go through customerdb or just the ones for my module?<br>
ie will drupal have any issues accessing the data it needs from say "drupaldb" if I dont change<br>
the active db back again?<br>
</blockquote>
<br></div>
db_set_active('customdb'); will make *all* queries run against customdb, until you call db_set_active(); to set it back to the default DB. For that reason, you should minimize the amount of work you do while using that DB. For instance:<br>
<br>
function dostuff() {<br>
<br>
$old_db = db_set_active('custom');<br>
<br>
$data = db_fetch_object(db_query("SELECT ..."));<br>
<br>
db_set_active($old_db);<br>
<br>
// Do some manipulation of $data here.<br>
<br>
return theme('mytheme_key', $data, $something_else);<br>
}<br>
<br>
Note that in the above, you put all of your DB interaction together in one place, switch the DB just long enough to run that, and then go back to normal. That ensures that once you get into theme calls or calling other Drupal functions you're back on the main Drupal database so that other code doesn't get confused.<br>
<br>
--Larry Garfield<br>
</blockquote></div><br><br>Sounds a lot easier to just query it from dedicated tables within the main drupal db.<br><br><br>