db_query
includes/database.inc, line 144
- Versions
- 4.6 – 6
db_query($query)- 7
db_query($query, $args = array(), $options = array())
Runs a basic query in the active database.
User-supplied arguments to the query should be passed in as separate parameters so that they can be properly escaped to avoid SQL injection attacks.
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 value
A database query result resource, or FALSE if the query was not executed correctly.
Related topics
- Database abstraction layer
- Allow the use of different database servers using the same code base.
▾ 292 functions call db_query()
- aggregator_block in modules/aggregator.module
- Implementation of hook_block().
- aggregator_cron in modules/aggregator.module
- Implementation of hook_cron().
- aggregator_form_feed in modules/aggregator.module
- aggregator_get_category in modules/aggregator.module
- aggregator_get_feed in modules/aggregator.module
- aggregator_menu in modules/aggregator.module
- Implementation of hook_menu().
- aggregator_page_categories in modules/aggregator.module
- Menu callback; displays all the categories used by the aggregator.
- aggregator_page_category in modules/aggregator.module
- Menu callback; displays all the items aggregated in a particular category.
- aggregator_page_opml in modules/aggregator.module
- Menu callback; generates an OPML representation of all feeds.
- aggregator_page_source in modules/aggregator.module
- Menu callback; displays all the items captured from a particular feed.
- aggregator_page_sources in modules/aggregator.module
- Menu callback; displays all the feeds used by the aggregator.
- aggregator_parse_feed in modules/aggregator.module
- aggregator_refresh in modules/aggregator.module
- Checks a news feed for new items.
- aggregator_remove in modules/aggregator.module
- aggregator_save_category in modules/aggregator.module
- aggregator_save_feed in modules/aggregator.module
- aggregator_save_item in modules/aggregator.module
- aggregator_view in modules/aggregator.module
- archive_calendar in modules/archive.module
- Generates a monthly calendar, for display in the archive block.
- block_admin_configure in modules/block.module
- Menu callback; displays the block configuration form.
- block_admin_save in modules/block.module
- block_block in modules/block.module
- Implementation of hook_block().
- block_box_delete in modules/block.module
- Menu callback; confirm and delete custom blocks.
- block_box_get in modules/block.module
- block_box_save in modules/block.module
- block_list in modules/block.module
- Return all blocks in the specied region for the current user. You may use this function to implement variable block regions. The default regions are 'left', 'right' and 'all', where 'all' means both left...
- block_user in modules/block.module
- Implementation of hook_user().
- blog_form in modules/blog.module
- Implementation of hook_form().
- book_admin_orphan in modules/book.module
- Menu callback; displays a listing of all orphaned book pages.
- book_admin_save in modules/book.module
- book_admin_view_book in modules/book.module
- book_block in modules/book.module
- Implementation of hook_block().
- book_delete in modules/book.module
- Implementation of hook_delete().
- book_insert in modules/book.module
- Implementation of hook_insert().
- book_load in modules/book.module
- Implementation of hook_load().
- book_location in modules/book.module
- Return the path (call stack) to a certain book page.
- book_location_down in modules/book.module
- book_menu in modules/book.module
- Implementation of hook_menu().
- book_next in modules/book.module
- Fetch the node object of the next page of the book.
- book_nodeapi in modules/book.module
- Implementation of hook_nodeapi().
- book_outline in modules/book.module
- Implementation of function book_outline() Handles all book outline operations.
- book_prev in modules/book.module
- Fetch the node object of the previous page of the book.
- book_print in modules/book.module
- Menu callback; generates printer-friendly book page with all descendants.
- book_print_recurse in modules/book.module
- book_render in modules/book.module
- Menu callback; prints a listing of all books.
- book_toc in modules/book.module
- book_tree in modules/book.module
- book_update in modules/book.module
- Implementation of hook_update().
- cache_clear_all in includes/bootstrap.inc
- Expire data from the cache.
- cache_get in includes/bootstrap.inc
- Return data from the persistent cache.
- cache_set in includes/bootstrap.inc
- Store data in the persistent cache.
- comment_admin_edit in modules/comment.module
- Menu callback; edit a comment from the administrative interface.
- comment_configure in modules/comment.module
- Menu callback; presents the comment settings page.
- comment_delete in modules/comment.module
- Menu callback; delete a comment.
- comment_edit in modules/comment.module
- comment_matrix_settings in modules/comment.module
- Menu callback; presents the moderation vote matrix.
- comment_moderate in modules/comment.module
- comment_moderation_form in modules/comment.module
- comment_nodeapi in modules/comment.module
- Implementation of hook_nodeapi().
- comment_num_all in modules/comment.module
- comment_num_new in modules/comment.module
- get number of new comments for current user and specified node
- comment_num_replies in modules/comment.module
- comment_post in modules/comment.module
- comment_preview in modules/comment.module
- comment_render in modules/comment.module
- comment_reply in modules/comment.module
- comment_role_settings in modules/comment.module
- Menu callback; allows admin to set default scores for different roles.
- comment_save in modules/comment.module
- comment_threshold_settings in modules/comment.module
- Menu callback; displays settings for thresholds at which comments are displayed.
- comment_validate_form in modules/comment.module
- comment_vote_settings in modules/comment.module
- Menu callback; displays page for assigning names to vote values.
- db_next_id in includes/database.pgsql.inc
- Return a new unique ID in the given sequence.
- do_search in modules/search.module
- Do a query on the full-text search index for a word or words.
- drupal_cron in modules/drupal.module
- Implementation of hook_cron(); handles pings to and from the site.
- drupal_directory_page in modules/drupal.module
- Formats a list of all sites indexed in the directory.
- drupal_directory_ping in modules/drupal.module
- Callback function from drupal_xmlrpc() called when another site pings this one.
- drupal_get_filename in includes/bootstrap.inc
- Returns and optionally sets the filename for a system item (module, theme, etc.). The filename, whether provided, cached, or retrieved from the database, is only returned if the file exists.
- drupal_get_path_map in includes/bootstrap.inc
- Return an array mapping path aliases to their internal Drupal paths.
- fileupload_delete in developer/examples/fileupload.module
- fileupload_file_download in developer/examples/fileupload.module
- fileupload_insert in developer/examples/fileupload.module
- fileupload_load in developer/examples/fileupload.module
- fileupload_update in developer/examples/fileupload.module
- filter_admin_add in modules/filter.module
- Add a new input format.
- filter_admin_delete in modules/filter.module
- Menu callback; confirm deletion of a format.
- filter_admin_filters_save in modules/filter.module
- Save enabled/disabled status for filters in a format.
- filter_admin_order_save in modules/filter.module
- Save the weights of filters in a format.
- filter_admin_save in modules/filter.module
- Save input formats on the overview page.
- filter_formats in modules/filter.module
- Retrieve a list of input formats.
- filter_format_allowcache in modules/filter.module
- Check if text in a certain input format is allowed to be cached.
- filter_list_format in modules/filter.module
- Retrieve a list of filters for a certain format.
- flood_is_allowed in includes/common.inc
- Check if the current visitor (hostname/IP) is allowed to proceed with the specified event. The user is allowed to proceed if he did not trigger the specified event more than $threshold times per hour.
- flood_register_event in includes/common.inc
- Register an event for the current visitor (hostname/IP) to the flood control mechanism.
- forum_delete in modules/forum.module
- Implementation of hook_delete().
- forum_get_forums in modules/forum.module
- Returns a list of all forums for a given taxonomy id
- forum_insert in modules/forum.module
- Implementation of hook_insert().
- forum_link in modules/forum.module
- Implementation of hook_link().
- forum_load in modules/forum.module
- Implementation of hook_load().
- forum_taxonomy in modules/forum.module
- Implementation of hook_taxonomy().
- forum_update in modules/forum.module
- Implementation of hook_update().
- forum_validate in modules/forum.module
- Implementation of hook_validate().
- hook_cron in developer/hooks/core.php
- Perform periodic actions.
- hook_delete in developer/hooks/node.php
- Respond to node deletion.
- hook_exit in developer/hooks/core.php
- Perform cleanup tasks.
- hook_init in developer/hooks/core.php
- Perform setup tasks.
- hook_insert in developer/hooks/node.php
- Respond to node insertion.
- hook_load in developer/hooks/node.php
- Load node-type-specific information.
- hook_update in developer/hooks/node.php
- Respond to node updating.
- list_themes in includes/theme.inc
- Provides a list of currently available themes.
- list_theme_engines in includes/theme.inc
- Provides a list of currently available theme engines
- locale in modules/locale.module
- Provides interface translation services
- locale_admin_manage in modules/locale.module
- Page handler for the language management screen
- locale_admin_manage_add in modules/locale.module
- Page handler for the language addition screen
- locale_admin_manage_delete_screen in modules/locale.module
- User interface for the language deletion confirmation screen
- locale_admin_string in modules/locale.module
- Page handler for the string search and administration screen
- locale_refresh_cache in modules/locale.module
- Refreshes database stored cache of translations
- locale_supported_languages in modules/locale.module
- Returns list of languages supported on this site
- menu_delete_item in modules/menu.module
- Menu callback; delete a single custom item.
- menu_disable_item in modules/menu.module
- Menu callback; hide a menu item.
- menu_edit_item in modules/menu.module
- Menu callback; dispatch to the appropriate menu item edit function.
- menu_edit_item_save in modules/menu.module
- Save changes to a menu item into the database.
- menu_rebuild in includes/menu.inc
- Populate the database representation of the menu.
- menu_reset in modules/menu.module
- Menu callback; clear the database, resetting the menu to factory defaults.
- menu_reset_item in modules/menu.module
- Menu callback; reset a single modified item.
- module_list in includes/module.inc
- Collect a list of all loaded modules. During the bootstrap, return only vital modules. See bootstrap.inc
- nodeapi_example_nodeapi in developer/examples/nodeapi_example.module
- Implementation of hook_nodeapi().
- node_access in modules/node.module
- Determine whether the current user may perform the given operation on the specified node.
- node_access_example_nodeapi in developer/examples/node_access_example.module
- Implementation of hook_nodeapi().
- node_access_view_all_nodes in modules/node.module
- Determine whether the user has a global viewing grant for all nodes.
- node_admin_nodes in modules/node.module
- Generate the content administration overview.
- node_comment_mode in modules/node.module
- Retrieve the comment mode for the given node ID (none, read, or read/write).
- node_cron in modules/node.module
- Implementation of hook_cron().
- node_delete in modules/node.module
- Ask for confirmation, and delete the node.
- node_example_delete in developer/examples/node_example.module
- Implementation of hook_delete().
- node_example_insert in developer/examples/node_example.module
- Implementation of hook_insert().
- node_example_load in developer/examples/node_example.module
- Implementation of hook_load().
- node_example_update in developer/examples/node_example.module
- Implementation of hook_update().
- node_last_changed in modules/node.module
- node_last_viewed in modules/node.module
- Retrieves the timestamp at which the current user last viewed the specified node.
- node_load in modules/node.module
- Load a node object from the database.
- node_page in modules/node.module
- Menu callback; dispatches control to the appropriate operation handler.
- node_save in modules/node.module
- Save a node object into the database.
- node_search in modules/node.module
- Implementation of hook_search().
- node_tag_new in modules/node.module
- Update the 'last viewed' timestamp of the specified node for current user.
- pager_query in includes/pager.inc
- Perform a paged database query.
- path_admin_delete in modules/path.module
- Menu callback; handles deletion of an URL alias.
- path_load in modules/path.module
- Fetch a specific URL alias from the database.
- path_nodeapi in modules/path.module
- Implementation of hook_nodeapi().
- path_save in modules/path.module
- Verify that a new URL alias is valid, and save it to the database.
- path_set_alias in modules/path.module
- Set an aliased path for a given Drupal path, preventing duplicates.
- ping_cron in modules/ping.module
- Implementation of hook_cron().
- poll_block in modules/poll.module
- Implementation of hook_block().
- poll_cron in modules/poll.module
- Implementation of hook_cron().
- poll_delete in modules/poll.module
- Implementation of hook_delete().
- poll_insert in modules/poll.module
- poll_load in modules/poll.module
- Implementation of hook_load().
- poll_update in modules/poll.module
- Implementation of hook_update().
- poll_vote in modules/poll.module
- Callback for processing a vote
- profile_admin_add in modules/profile.module
- Menu callback; adds a new field to all user profiles.
- profile_admin_delete in modules/profile.module
- Menu callback; deletes a field from all user profiles.
- profile_admin_edit in modules/profile.module
- Menu callback; displays the profile field editing form.
- profile_admin_overview in modules/profile.module
- Menu callback; display a listing of all editable profile fields.
- profile_browse in modules/profile.module
- Menu callback; display a list of user information.
- profile_categories in modules/profile.module
- profile_form_profile in modules/profile.module
- profile_load_profile in modules/profile.module
- profile_save_profile in modules/profile.module
- profile_validate_profile in modules/profile.module
- profile_view_profile in modules/profile.module
- queue_count in modules/queue.module
- queue_nodeapi in modules/queue.module
- Implementation of hook_nodeapi().
- queue_score in modules/queue.module
- queue_vote in modules/queue.module
- search_cron in modules/search.module
- Implementation of hook_cron().
- search_index in modules/search.module
- Update the full-text search index for a particular item.
- search_wipe in modules/search.module
- Wipes a part of or the entire search index.
- sess_destroy in includes/session.inc
- sess_gc in includes/session.inc
- sess_read in includes/session.inc
- sess_write in includes/session.inc
- statistics_access_log in modules/statistics.module
- statistics_cron in modules/statistics.module
- Implementation of hook_cron().
- statistics_exit in modules/statistics.module
- Implementation of hook_exit().
- statistics_get in modules/statistics.module
- Retrieves a node's "view statistics".
- statistics_nodeapi in modules/statistics.module
- Implementation of hook_nodeapi().
- system_get_files_database in modules/system.module
- Retrieves the current status of an array of files in the system table.
- system_listing_save in modules/system.module
- system_module_listing in modules/system.module
- Generate a list of all the available modules, as well as update the system list.
- system_theme_data in modules/system.module
- Collect data about all currently available themes
- taxonomy_del_term in modules/taxonomy.module
- taxonomy_del_vocabulary in modules/taxonomy.module
- taxonomy_get_children in modules/taxonomy.module
- Find all children of a term ID.
- taxonomy_get_parents in modules/taxonomy.module
- Find all parents of a given term ID.
- taxonomy_get_related in modules/taxonomy.module
- Find all term objects related to a given term ID.
- taxonomy_get_synonyms in modules/taxonomy.module
- Return an array of synonyms of the given term ID.
- taxonomy_get_synonym_root in modules/taxonomy.module
- Return the term object that has the given string as a synonym.
- taxonomy_get_term in modules/taxonomy.module
- Return the term object matching a term ID.
- taxonomy_get_term_by_name in modules/taxonomy.module
- Try to map a string to an existing term, as for glossary use.
- taxonomy_get_tree in modules/taxonomy.module
- Create a hierarchical representation of a vocabulary.
- taxonomy_get_vocabularies in modules/taxonomy.module
- Return an array of all vocabulary objects.
- taxonomy_get_vocabulary in modules/taxonomy.module
- Return the vocabulary object matching a vocabulary ID.
- taxonomy_node_delete in modules/taxonomy.module
- Remove associations of a node to its terms.
- taxonomy_node_form in modules/taxonomy.module
- Generate a form for selecting terms to associate with a node.
- taxonomy_node_get_terms in modules/taxonomy.module
- Find all terms associated to the given node.
- taxonomy_node_get_terms_by_vocabulary in modules/taxonomy.module
- Find all terms associated to the given node, within one vocabulary.
- taxonomy_node_save in modules/taxonomy.module
- Save term associations for a given node.
- taxonomy_save_term in modules/taxonomy.module
- taxonomy_save_vocabulary in modules/taxonomy.module
- taxonomy_term_count_nodes in modules/taxonomy.module
- Given a term id, count the number of published nodes in it.
- taxonomy_term_page in modules/taxonomy.module
- Menu callback; displays all nodes associated with a term.
- theme_aggregator_page_item in modules/aggregator.module
- Format an individual feed item for display on the aggregator page.
- theme_comment_threshold in modules/comment.module
- throttle_exit in modules/throttle.module
- Implementation of hook_exit().
- update_101 in database/updates.inc
- update_105 in database/updates.inc
- update_108 in database/updates.inc
- update_109 in database/updates.inc
- update_114 in database/updates.inc
- update_118 in database/updates.inc
- update_120 in database/updates.inc
- update_124 in database/updates.inc
- update_130 in database/updates.inc
- update_33 in database/updates.inc
- update_37 in database/updates.inc
- update_40 in database/updates.inc
- update_47 in database/updates.inc
- update_52 in database/updates.inc
- update_59 in database/updates.inc
- update_63 in database/updates.inc
- update_66 in database/updates.inc
- update_68 in database/updates.inc
- update_80 in database/updates.inc
- update_85 in database/updates.inc
- update_89 in database/updates.inc
- update_97 in database/updates.inc
- update_98 in database/updates.inc
- update_99 in database/updates.inc
- update_data in ./update.php
- update_page in ./update.php
- update_sql in database/updates.inc
- upload_count_size in modules/upload.module
- upload_delete in modules/upload.module
- upload_file_download in modules/upload.module
- upload_load in modules/upload.module
- upload_save in modules/upload.module
- user_access in modules/user.module
- Determine whether the user has a given privilege.
- user_admin_access in modules/user.module
- Menu callback: list all access rules
- user_admin_access_add in modules/user.module
- Menu callback: add an access rule
- user_admin_access_delete in modules/user.module
- Menu callback: delete an access rule
- user_admin_access_edit in modules/user.module
- Menu callback: edit an access rule
- user_admin_account in modules/user.module
- user_admin_perm in modules/user.module
- Menu callback: administer permissions.
- user_admin_role in modules/user.module
- Menu callback: administer roles.
- user_block in modules/user.module
- Implementation of hook_block().
- user_deny in modules/user.module
- user_edit in modules/user.module
- user_edit_validate in modules/user.module
- user_external_load in modules/user.module
- user_fields in modules/user.module
- user_get_authmaps in modules/user.module
- Accepts an user object, $account, or a DA name and returns an associative array of modules and DA names. Called at external login.
- user_get_authname in modules/user.module
- Called by authentication modules in order to edit/view their authmap information.
- user_load in modules/user.module
- Fetch a user object.
- user_login in modules/user.module
- user_roles in modules/user.module
- user_save in modules/user.module
- Save changes to a user account.
- user_set_authmaps in modules/user.module
- user_validate_authmap in modules/user.module
- variable_del in includes/bootstrap.inc
- Unset a persistent variable.
- variable_init in includes/bootstrap.inc
- Load the persistent variable table.
- variable_set in includes/bootstrap.inc
- Set a persistent variable.
- watchdog in includes/bootstrap.inc
- Log a system message.
- watchdog_cron in modules/watchdog.module
- Implementation of hook_cron().
- watchdog_event in modules/watchdog.module
- Menu callback; displays details about a log message.
- _aggregator_page_list in modules/aggregator.module
- Prints an aggregator page listing a number of feed items. Various menu callbacks use this function to print their feeds.
- _block_rehash in modules/block.module
- Update the 'blocks' DB table with the blocks currently exported by modules.
- _comment_delete_thread in modules/comment.module
- _comment_update_node_statistics in modules/comment.module
- Updates the comment statistics for a given node. This should be called any time a comment is added, deleted, or updated.
- _filter_tips in modules/filter.module
- Helper function for fetching filter tips.
- _forum_get_vid in modules/forum.module
- Returns the vocabulary id for forum navigation.
- _forum_topics_read in modules/forum.module
- _forum_user_last_visit in modules/forum.module
- _locale_add_language in includes/locale.inc
- Helper function to add a language
- _locale_admin_manage_screen in includes/locale.inc
- User interface for the language management screen
- _locale_export_po in includes/locale.inc
- Exports a Portable Object (Template) file for a language
- _locale_import_po in includes/locale.inc
- Parses Gettext Portable Object file information and inserts into database
- _locale_string_delete in includes/locale.inc
- _locale_string_edit in includes/locale.inc
- User interface for string editing
- _locale_string_save in includes/locale.inc
- Action handler for string editing
- _menu_build in includes/menu.inc
- Build the menu by querying both modules and the database.
- _taxonomy_term_children in modules/taxonomy.module
- Helper for taxonomy_term_count_nodes().
- _user_authenticated_id in modules/user.module
- _watchdog_get_message_types in modules/watchdog.module
Code
<?php
function db_query($query) {
$args = func_get_args();
$query = db_prefix_tables($query);
if (count($args) > 1) {
if (is_array($args[1])) {
$args = array_merge(array($query), $args[1]);
}
$args = array_map('db_escape_string', $args);
$args[0] = $query;
$query = call_user_func_array('sprintf', $args);
}
return _db_query($query);
}
?> 