I've inherited some code. It works, but I'm wondering what the "5" does in this db_query statement.

$result = db_query(5, "SELECT * FROM {foo} WHERE bar = '%d'", $bar_val);
  • 1
    No version of db_query takes anything other than a query string as the first parameter - if it works, I'd wager someone has altered the core function to accept that numeric parameter for whatever reason.
    – Clive
    Commented Jul 14, 2015 at 20:02
  • you're right. the previous owner hacked core and changed the function. thanks! do you want to restate your comment as an answer?
    – sTony
    Commented Jul 15, 2015 at 21:11

1 Answer 1


The first argument taken from db_query() is the query string to execute; the next parameters are the values of the placeholders used in the query strings.

If you see code similar to the one you show, it means the content of includes/database.mysql-common.inc, or includes/database.pgsql.inc (depending on the database engine used) has been changed to alter the first parameter used from db_query(). If you are using third-party database drivers, check the database.<database-engine>.inc file that should come with that database driver.

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.