Approach to adapting a traditional PHP solution into a Drupal module I find that traditional PHP development strategies don't help a great deal when trying to mould Drupal into areas it isn't directly built for and I'm hoping for assistance in how I might approach Drupal module development starting with a traditional approach.

I specifically have a project where I know pretty much how I would tackle it in PHP but am a babe in the woods trying to get this to work in Drupal.

I have new tables that I'm adding to the database that reference the 'user' and 'node' Drupal tables. The data used in the site from these tables will have some fairly complex SQL joins etc.

I will be needing a block or two; some summary pages; various admin pages; and permissions and access control for different items.

I've generated my rough wireframes but now I need to get this working in Drupal!

My traditional approach would be to create a class file for the data handling and then build pages or classes to handle the various views and controllers. Template files would be used for individual pages/blocks.

With this in mind what is the best approach to make this work in Drupal - or do I really need to think differently?

For my development environment I'm using PhpEd and running DrupalForFirebug in Firefox. I also use the Devel module and Themer where I need to. Building themes in Drupal is not a big issue for me but modules are something I've avoided.

Thanks :)
Here is what I would do (Drupal 7 assumed):


Look into http://api.drupal.org/api/drupal/modules--system--system.api.php/function/hook_schema/7 for defining your tables. You don't need to do anything special to reference node and user; Drupal doesn't make heavy use of foreign keys. Look into the database abstraction layer to get an idea of the functions you can use to interact with the database. db_select is particularly cool and naturally supports joins.
You may also want to look into Data and Views. Through the use of these modules, you may be able to cut down on the amount of custom code you have to write.
For the blocks, it depends on if they have dynamic or static content. If dynamic, look into Example: Block. If static, check out the Boxes module. Also look into Context as an alternative for placing the blocks instead of using the block visibility settings. This is assuming I understood your use of terminology when you said blocks.
For the pages, look into hook_menu. You can define your own this way; of course, you can also just create pages through the interface...so it depends again on what you meant.
Your development environment sounds fine. You'll find the tools you like as you go along.
There'll be a learning curve, but what you learn will be extremely reusable across future sites you build. It's worth it.