views:

268

answers:

2

I have a few custom tables in my Drupal database that were created manually. Is there some Drupal module to allow viewing and editing records in custom tables? Tables are simple, no joins used.

Or it's best to build some grid/record interfaces manually in custom module?

+2  A: 

For reporting, the recommended way is likely to use Views integration. If your tables have primary keys, it's a simple matter of defining them to Views by implementing:

  • hook_views_api() to declare Views integration
  • hook_views_data() to declare the tables and their fields, assuming they use only simple data types

You can take the integration examples in views/modules/node.views.inc and views/modules/node/*. Module TableWizard can help you with this.

This still won't provide you with editability, though. For this, you could either build the module on your own using Form API, or import the content of these tables as nodes, and use drupal builtin editing on the nodes, assuming you do not mind the data being in node format after that.

FGM
+1 for Table Wizard.
theunraveler
A: 

You might consider using both Views and the new Data module:

The Data module provides

    * an API for dynamically allocating tables for single-row records.
    * an API for insert/update/delete operations and describing how tables join to each other.
    * automatic views integration.
    * a way to export table definitions to code.

The included Data UI module provides

    * UI to add new database tables.
    * UI to add or alter columns to existing tables managed by Data module.
    * UI to define joins between tables.
    * UI to solve conflicts between table in database and schema information.
    * default views for tables managed by Data module.
    * UI to add existing tables that are unclaimed by other modules to Data's table management.
threecheeseopera
Link to data: http://drupal.org/project/data
Tom