Figuring out db_query()
Yeah, I use it all the time. But there's a few things about Drupal's db_query (and the database-specific MySQL etc. functions behind it, and Drupal functions like db_fetch_object() that I'd like to have very clear in my head:
- If the query is successful but results in an empty set, is
$result
still a numeric reference or just zero?
Parameters
$query A string containing an SQL query.
... A variable number of arguments which are substituted into the query using printf() syntax. Instead of a variable number of query arguments, you may also pass a single array containing the query arguments.
Return valueA database query result resource, or FALSE if the query was not executed correctly.
Just a side note, but that "..." for "A variable number of arguments" really drives home the case Larry Garfield has made against that setup. The function can't even define itself!
See also setting errors in Drupal (Agaric's guide in progress) for reporting SQL errors.
See also agaric's page on db_last_insert_id().
Comments
Post new comment