[development] Database schema abstraction and *reflection* (was: Referential integrity -- finally?)

Barry Jaspan barry at mit.edu
Fri Jan 26 19:17:05 UTC 2007

Moshe Weitzman <weitzman at tejasa.com> writes:
> actually, drupal core itself uses basic reflection on the users
> table. see user_fields(). ... this
> table definition API would help us extend that feature to other
> objects like $node and $term. Very nice for performance.

Yes.  Just to spell this out, a hypothetical hook_schema_alter for

function foo_schema_alter(&$schema) {
  $schema['node']['cols'][] = array(/* define the foo column for nodes */);

Now, node_load and node_save automatically handle $node->foo, so
foo_nodeapi doesn't have to do its own queries.  Of course this only
makes sense for data that applies to every node (a node type's custom
columns should not (?) exist in the node table as they'd be NULL most
of the time and we'd get a very wide table).


More information about the development mailing list