I'd like to convert the instructions from this answer into a general script that can be reused across projects.

I'm wondering how these commands can be written in Drupal 7 PDO format:

UPDATE `system` SET filename = replace(filename, 'sites/all/modules/contrib', 'profiles/distroname/modules/contrib');

Is the mysql replace function something generic to all SQL, or is it mysql specific? I understand this is an expression, but I'm not clear on how to use the PDO expression syntax in this case.

What are the advantages of writing it PDO, as opposed to just a simple db_query() with the sql query from above? In PDO, will this truly be db agnostic?

1 Answer 1


Would it be something like this?

  expression('filename', 'replace(filename, :old, :new)', array(
    ':old' => 'sites/all/modules/contrib',
    ':new' => 'profiles/distroname/modules/contrib'

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.