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

Andrew Berry andrewberry at sentex.net
Mon Nov 16 21:26:14 UTC 2009

On 16/11/2009 10:29 AM, Jennifer Hodgdon wrote:
> 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(). 
I don't understand this approach. Why can't hook_menu and a custom load 
function be used to do this, while separating the theme from the data?

function mymodule_menu() {
   $items['customers/%customer'] = array(
     // Insert items here as per hook_menu docs.

function customer_load($customer_id) {
   // It's probably better to select fields, not * - there was 
discussion about this
   // previously I think.
   $customer = db_fetch_object("SELECT * FROM {customer_data} WHERE 
customer_id = %d", $customer_id);
   return $customer;

More information about the development mailing list