I think the answer should be easy but I can't find it.

maybe I've been put in the wrong direction finding sites telling how to clear my flood table like so:

drush php-eval 'db_query("DELETE FROM `flood`");'

But I think is should be like this so it also works for prefixed tables:

drush php-eval 'db_query("DELETE FROM `{flood}`");'

Or does db_query() works different in drush php-eval? As far as I know it just executes php but does it has the drupal 'library' available or not?

Now I could just try and see what happens but I think it's good to really know if there's a difference or not in running db_query() from drush or from code.

1 Answer 1


I don't know this for definite but conceptually speaking, if Drush didn't use a standard Drupal bootstrap to perform these tasks it would have to re-implement all of that functionality itself.

Drush uses your site's settings.php file for the database connection, which leads me to believe it will also have access to things like $db_prefix.

I think it's safe to say exactly the same thing is happening when you run db_query() from Drush as if you run it from any other bootstrapped instance of Drupal.

  • 2
    Yes, that is absolutely correct for php-eval: the code will execute in the same environment that it does when running from within a Drupal site, so prefixed tables will be handled for {flood} and similar. However, please note that the sql-query command avoids modifying your query in any way unless you specify the --db-prefix option. The sql-query version of the above example would therefore be: drush sql-query --db-prefix 'DELETE FROM {flood};' (please excuse quoting variation; stack exchange code filter in effect) Sep 24, 2012 at 16:09

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.