I am currently writing two modules - one is an extension of the other that needs to be a separate module for various reasons. The extension module needs to add a whole bunch of fields to a form generated by the base module, and then needs to attach some SQL to a query from the base module during form submission. My question is, is it possible to use db_rewrite_sql with placeholders? If so, is it possible to access the placeholder values when invoking hook_db_rewrite_sql?

Comments

xjm’s picture

The solution to this is probably the same as with update_sql():
http://api.drupal.org/api/function/update_sql/6#comment-412

jaypan’s picture

Yes you can add placeholders:

db_rewrite_sql($query, $primary_table = 'n', $primary_field = 'nid', $args = array())

In the $args.

And you can access those args in hook_rewrite_db_sql:

hook_db_rewrite_sql($query, $primary_table, $primary_field, $args)

Contact me to contract me for D7 -> D10/11 migrations.