Using D7, I noticed that I can't use a placeholder for the table name in any db_* functions. I can't seem to find any info why, apologize if it has been discussed.

The only way around it has been to stringify the name. For instance, {".$db_table."}. I realize, with the newer D7 Database API this is not that big a deal; however, when you want to preserve an older query string, this becomes an issue.

Thanks

Comments

Crell’s picture

Status: Active » Closed (works as designed)

That's because we're not using pseudo-placeholders anymore. We're using DB-native placeholders, which have actual significance in SQL rather than being just a simple str_replace().

If you have a dynamic table name, you can either inject it into the string manually (after sanitizing it yourself!) or use the query builders to create the query, as you pass the table name into the factory function.