What is the first parameter of this db_query call for? 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);
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.&lt;database-engine&gt;.inc file that should come with that database driver.