[development] new dev q: are mysql queries possible within drupal?

Jennifer Hodgdon yahgrp at poplarware.com
Mon Nov 16 15:29:23 UTC 2009


spartaguy spartaguy wrote:
>  I want to do a select on a table and just display the results in main
> window pane.
> 
> ie header is standard logo, left hand side is navigation menu.
> One of the navigation items should be able to do a query on a table in the
> local drupal database or ideally in a separate database.
> 
> the mysql syntax is the easy part. its the creating a menu item that will do
> the mysql select statement and display the results in the main window pane.

Are you really talking about a menu item or a block here?

If you just want to add a section to the left sidebar that displays 
the results of your query, then in Drupal terms, you need to create a 
"block" in a module, which an administrator can then activate and 
display in the left sidebar on the Blocks admin page. This section of 
the Module Tutorial on drupal.org will get you started with block 
programming:
    http://drupal.org/node/206758

If you need the left sidebar section to appear inside of an existing 
Drupal Menu (Navigation, Primary Links, or another one defined on the 
Menus admin page) that is being displayed on the left sidebar, then I 
think your best bet would be:
a) Add a "dummy" placeholder menu item to the menu, within the admin 
interface, where you want your query results to appear.
b) In your theme, make a custom theme function for theme('menu_item') 
that will detect the dummy item and do your query, and otherwise just 
call theme_menu_item().
There is information on how to override theme functions here:
http://drupal.org/node/341628

Good luck!
     Jennifer


-- 
Jennifer Hodgdon * Poplar ProductivityWare
www.poplarware.com
Drupal, WordPress, and custom Web programming



More information about the development mailing list