| 7 database.inc | db_delete($table, array $options = array()) |
| 8 database.inc | db_delete($table, array $options = array()) |
Returns a new DeleteQuery object for the active database.
Parameters
$table: The table from which to delete.
$options: An array of options to control how the query operates.
Return value
DeleteQuery A new DeleteQuery object for this connection.
Related topics
- Database abstraction layer
- Allow the use of different database servers using the same code base.
▾ 166 functions call db_delete()
- ActionLoopTestCase::testActionLoop in modules/
simpletest/ tests/ actions.test - Set up a loop with 3 - 12 recursions, and see if it aborts properly.
- actions_delete in includes/
actions.inc - Deletes a single action from the database.
- aggregator_aggregator_remove in modules/
aggregator/ aggregator.processor.inc - Implements hook_aggregator_remove().
- aggregator_categorize_items_submit in modules/
aggregator/ aggregator.pages.inc - Form submission handler for aggregator_categorize_items().
- aggregator_expire in modules/
aggregator/ aggregator.processor.inc - Expires items from a feed depending on expiration settings.
- aggregator_save_category in modules/
aggregator/ aggregator.module - Adds/edits/deletes aggregator categories.
- aggregator_save_feed in modules/
aggregator/ aggregator.module - Add/edit/delete an aggregator feed.
- aggregator_save_item in modules/
aggregator/ aggregator.processor.inc - Adds/edits/deletes an aggregator item.
- block_admin_configure_submit in modules/
block/ block.admin.inc - Form submission handler for block_admin_configure().
- block_custom_block_delete_submit in modules/
block/ block.admin.inc - Form submission handler for block_custom_block_delete().
- block_menu_delete in modules/
block/ block.module - Implements hook_menu_delete().
- block_modules_uninstalled in modules/
block/ block.module - Implements hook_modules_uninstalled().
- block_user_role_delete in modules/
block/ block.module - Implements hook_user_role_delete().
- book_node_delete in modules/
book/ book.module - Implements hook_node_delete().
- book_remove_form_submit in modules/
book/ book.pages.inc - Confirm form submit function to remove a node from the book.
- book_uninstall in modules/
book/ book.install - Implements hook_uninstall().
- CommentInterfaceTest::setEnvironment in modules/
comment/ comment.test - Re-configures the environment, module settings, and user permissions.
- comment_delete_multiple in modules/
comment/ comment.module - Delete comments and all their replies.
- comment_node_delete in modules/
comment/ comment.module - Implements hook_node_delete().
- ContactPersonalTestCase::testPersonalContactFlood in modules/
contact/ contact.test - Tests the personal contact form flood protection.
- ContactSitewideTestCase::testSiteWideContact in modules/
contact/ contact.test - Tests configuration options and the site-wide contact form.
- contact_category_delete_form_submit in modules/
contact/ contact.admin.inc - Form submission handler for contact_category_delete_form().
- DatabaseDeleteTruncateTestCase::testSimpleDelete in modules/
simpletest/ tests/ database_test.test - Confirm that we can delete a single record successfully.
- DatabaseDeleteTruncateTestCase::testSubselectDelete in modules/
simpletest/ tests/ database_test.test - Confirm that we can use a subselect in a delete successfully.
- DBLogTestCase::testFilter in modules/
dblog/ dblog.test - Test the dblog filter on admin/reports/dblog.
- dblog_clear_log_submit in modules/
dblog/ dblog.admin.inc - Submit callback: clear database with log messages.
- dblog_cron in modules/
dblog/ dblog.module - Implements hook_cron().
- DrupalDatabaseCache::clear in includes/
cache.inc - Implements DrupalCacheInterface::clear().
- DrupalDatabaseCache::garbageCollection in includes/
cache.inc - Garbage collection for get() and getMultiple().
- DrupalTestCase::deleteAssert in modules/
simpletest/ drupal_web_test_case.php - Delete an assertion record by message ID.
- drupal_session_destroy_uid in includes/
session.inc - Ends a specific user's session(s).
- field_create_field in modules/
field/ field.crud.inc - Creates a field.
- field_purge_field in modules/
field/ field.crud.inc - Purges a field record from the database.
- field_purge_instance in modules/
field/ field.crud.inc - Purges a field instance record from the database.
- field_sql_storage_field_storage_delete_revision in modules/
field/ modules/ field_sql_storage/ field_sql_storage.module - Implements hook_field_storage_delete_revision().
- field_sql_storage_field_storage_purge in modules/
field/ modules/ field_sql_storage/ field_sql_storage.module - Implements hook_field_storage_purge().
- field_sql_storage_field_storage_write in modules/
field/ modules/ field_sql_storage/ field_sql_storage.module - Implements hook_field_storage_write().
- file_delete in includes/
file.inc - Delete a file and its database record.
- file_usage_delete in includes/
file.inc - Removes a record to indicate that a module is no longer using a file.
- filter_update_7003 in modules/
filter/ filter.install - Upgrade the {filter} table for core filters.
- flood_clear_event in includes/
common.inc - Makes the flood control mechanism forget an event for the current visitor.
- forum_field_storage_pre_update in modules/
forum/ forum.module - Implements hook_field_storage_pre_update().
- forum_node_delete in modules/
forum/ forum.module - Implements hook_node_delete().
- forum_node_update in modules/
forum/ forum.module - Implements hook_node_update().
- HookBootExitTestCase::testHookBootExit in modules/
simpletest/ tests/ bootstrap.test - Test calling of hook_boot() and hook_exit().
- hook_actions_delete in modules/
system/ system.api.php - Executes code after an action is deleted.
- hook_cron in modules/
system/ system.api.php - Perform periodic actions.
- hook_delete in modules/
node/ node.api.php - Respond to node deletion.
- hook_entity_delete in modules/
system/ system.api.php - Act on entities when deleted.
- hook_field_purge_field in modules/
field/ field.api.php - Acts when a field record is being purged.
- hook_field_purge_instance in modules/
field/ field.api.php - Acts when a field instance is being purged.
- hook_field_storage_delete_revision in modules/
field/ field.api.php - Delete a single revision of field data for an entity.
- hook_field_storage_pre_update in modules/
field/ field.api.php - Act before the storage backends update field data.
- hook_field_storage_purge in modules/
field/ field.api.php - Remove field storage information when field data is purged.
- hook_field_storage_purge_field_instance in modules/
field/ field.api.php - Remove field storage information when a field instance is purged.
- hook_field_storage_write in modules/
field/ field.api.php - Write field data for an entity.
- hook_field_update in modules/
field/ field.api.php - Define custom update behavior for this module's field types.
- hook_file_delete in modules/
system/ system.api.php - Respond to a file being deleted.
- hook_menu_link_delete in modules/
system/ system.api.php - Inform modules that a menu link has been deleted.
- hook_modules_uninstalled in modules/
system/ system.api.php - Perform necessary actions after modules are uninstalled.
- hook_node_delete in modules/
node/ node.api.php - Respond to node deletion.
- hook_node_revision_delete in modules/
node/ node.api.php - Respond to deletion of a node revision.
- hook_path_delete in modules/
path/ path.api.php - Allow modules to respond to a path being deleted.
- hook_taxonomy_term_delete in modules/
taxonomy/ taxonomy.api.php - Respond to the deletion of taxonomy terms.
- hook_user_cancel in modules/
user/ user.api.php - Act on user account cancellations.
- hook_user_delete in modules/
user/ user.api.php - Respond to user deletion.
- hook_user_role_delete in modules/
user/ user.api.php - Inform other modules that a user role has been deleted.
- image_default_style_revert in modules/
image/ image.module - Revert the changes made by users to a default image style.
- image_effect_delete in modules/
image/ image.module - Delete an image effect.
- image_style_delete in modules/
image/ image.module - Delete an image style.
- ImportOPMLTestCase::openImportForm in modules/
aggregator/ aggregator.test - Open OPML import form.
- ImportOPMLTestCase::submitImportForm in modules/
aggregator/ aggregator.test - Submit form with invalid, empty and valid OPML files.
- locale_date_format_reset_form_submit in modules/
locale/ locale.admin.inc - Reset date formats for a specific language to global defaults.
- locale_languages_delete_form_submit in modules/
locale/ locale.admin.inc - Process language deletion submissions.
- locale_translate_delete_form_submit in modules/
locale/ locale.admin.inc - Process string deletion submissions.
- locale_translate_edit_form_submit in modules/
locale/ locale.admin.inc - Process string editing form submissions.
- lock_may_be_available in includes/
lock.inc - Check if lock acquired by a different process may be available.
- lock_release in includes/
lock.inc - Release a lock previously acquired by lock_acquire().
- lock_release_all in includes/
lock.inc - Release all previously acquired locks.
- MenuLinksUnitTestCase::testMenuLinkReparenting in modules/
simpletest/ tests/ menu.test - Test automatic reparenting of menu links.
- MenuLinksUnitTestCase::testMenuLinkRouterReparenting in modules/
simpletest/ tests/ menu.test - Test automatic reparenting of menu links derived from menu routers.
- MenuRebuildTestCase::testMenuRebuildByVariable in modules/
simpletest/ tests/ menu.test - Test if the 'menu_rebuild_needed' variable triggers a menu_rebuild() call.
- menu_delete in modules/
menu/ menu.module - Delete a custom menu and all contained links.
- NodeAccessUnitTest::setUp in modules/
node/ node.test - Generates a random database prefix, runs the install scripts on the prefixed database and enable the specified modules. After installation many caches are flushed and the internal browser is setup so that the page requests will run on the new prefix.…
- node_access_rebuild in modules/
node/ node.module - Rebuild the node access database. This is occasionally needed by modules that make system-wide changes to access levels.
- node_access_test_node_delete in modules/
node/ tests/ node_access_test.module - node_access_write_grants in modules/
node/ node.module - Writes a list of grants to the database, deleting any previously saved ones.
- node_cron in modules/
node/ node.module - Implements hook_cron().
- node_delete_multiple in modules/
node/ node.module - Delete multiple nodes.
- node_form_block_admin_configure_submit in modules/
node/ node.module - Form submit handler for block configuration form.
- node_form_block_custom_block_delete_submit in modules/
node/ node.module - Form submit handler for custom block delete form.
- node_modules_uninstalled in modules/
node/ node.module - Implements hook_modules_uninstalled().
- node_revision_delete in modules/
node/ node.module - Delete a node revision.
- node_type_delete in modules/
node/ node.module - Deletes a node type from the database.
- node_user_cancel in modules/
node/ node.module - Implements hook_user_cancel().
- node_user_delete in modules/
node/ node.module - Implements hook_user_delete().
- openid_association in modules/
openid/ openid.module - Attempt to create a shared secret with the OpenID Provider.
- openid_cron in modules/
openid/ openid.module - Remove expired nonces from the database.
- openid_user_delete_form_submit in modules/
openid/ openid.pages.inc - openid_verify_assertion in modules/
openid/ openid.module - Attempt to verify the response received from the OpenID Provider.
- PathLookupTest::testDrupalLookupPath in modules/
simpletest/ tests/ path.test - Test that drupal_lookup_path() returns the correct path.
- path_delete in includes/
path.inc - Delete a URL alias.
- poll_cancel in modules/
poll/ poll.module - Submit callback for poll_cancel_form().
- poll_delete in modules/
poll/ poll.module - Implements hook_delete().
- poll_update in modules/
poll/ poll.module - Implements hook_update().
- poll_update_7001 in modules/
poll/ poll.install - Use the poll_choice primary key to record votes in poll_votes rather than the choice order. Rename chorder to weight.
- poll_user_delete in modules/
poll/ poll.module - Implements hook_user_delete().
- profile_field_delete_submit in modules/
profile/ profile.admin.inc - Process a field delete form submission.
- profile_user_cancel in modules/
profile/ profile.module - Implements hook_user_cancel().
- profile_user_delete in modules/
profile/ profile.module - Implements hook_user_delete().
- rdf_mapping_delete in modules/
rdf/ rdf.module - Deletes the mapping for the given bundle from the database.
- search_index in modules/
search/ search.module - Update the full-text search index for a particular item.
- search_reindex in modules/
search/ search.module - Clears a part of or the entire search index.
- search_update_totals in modules/
search/ search.module - Updates the {search_total} database table.
- shortcut_set_delete in modules/
shortcut/ shortcut.module - Deletes a shortcut set.
- shortcut_set_unassign_user in modules/
shortcut/ shortcut.module - Unassigns a user from any shortcut set they may have been assigned to.
- simpletest_clean_results_table in modules/
simpletest/ simpletest.module - Clear the test result tables.
- statistics_cron in modules/
statistics/ statistics.module - Implements hook_cron().
- statistics_node_delete in modules/
statistics/ statistics.module - Implements hook_node_delete().
- statistics_user_delete in modules/
statistics/ statistics.module - Implements hook_user_delete().
- SystemQueue::deleteItem in modules/
system/ system.queue.inc - SystemQueue::deleteQueue in modules/
system/ system.queue.inc - system_cron in modules/
system/ system.module - Implements hook_cron().
- system_date_format_delete in modules/
system/ system.module - Deletes a date format from the database.
- system_date_format_type_delete in modules/
system/ system.module - Deletes a date type from the database.
- system_ip_blocking_delete_submit in modules/
system/ system.admin.inc - Process system_ip_blocking_delete form submissions.
- system_update_7003 in modules/
system/ system.install - Update {blocked_ips} with valid IP addresses from {access}.
- system_update_7063 in modules/
system/ system.install - Delete {menu_links} records for 'type' => MENU_CALLBACK which would not appear in a fresh install.
- system_update_7065 in modules/
system/ system.install - Remove the default value for sid.
- system_update_files_database in modules/
system/ system.module - Updates the records in the system table based on the files array.
- taxonomy_delete_node_index in modules/
taxonomy/ taxonomy.module - Deletes taxonomy index entries for a given node.
- taxonomy_taxonomy_term_delete in modules/
taxonomy/ taxonomy.module - Implements hook_taxonomy_term_delete().
- taxonomy_term_delete in modules/
taxonomy/ taxonomy.module - Delete a term.
- taxonomy_term_save in modules/
taxonomy/ taxonomy.module - Saves a term object to the database.
- taxonomy_test_taxonomy_term_delete in modules/
simpletest/ tests/ taxonomy_test.module - Implements hook_taxonomy_term_delete().
- taxonomy_vocabulary_delete in modules/
taxonomy/ taxonomy.module - Delete a vocabulary.
- TrackerTest::testTrackerCronIndexing in modules/
tracker/ tracker.test - Test that existing nodes are indexed by cron.
- tracker_cron in modules/
tracker/ tracker.module - Implements hook_cron().
- tracker_node_delete in modules/
tracker/ tracker.module - Implements hook_node_delete().
- trigger_actions_delete in modules/
trigger/ trigger.module - Implements hook_actions_delete().
- trigger_assign_form_submit in modules/
trigger/ trigger.admin.inc - Submit function for trigger_assign_form().
- trigger_unassign_submit in modules/
trigger/ trigger.admin.inc - Submit callback for trigger_unassign() form.
- update_fix_d7_block_deltas in includes/
update.inc - A helper function that modules can use to assist with the transformation from numeric block deltas to string block deltas during the 6.x -> 7.x upgrade.
- UpgradePathTestCase::uninstallModulesExcept in modules/
simpletest/ tests/ upgrade/ upgrade.test - Force uninstall all modules from a test database, except those listed.
- UpgradePathTestCase::variable_set in modules/
simpletest/ tests/ upgrade/ upgrade.test - Specialized variable_set() that works even if the child site is not upgraded.
- user_delete_multiple in modules/
user/ user.module - Delete multiple user accounts.
- user_modules_uninstalled in modules/
user/ user.module - Implements hook_modules_uninstalled().
- user_role_delete in modules/
user/ user.module - Delete a user role from database.
- user_role_revoke_permissions in modules/
user/ user.module - Revoke permissions from a user role.
- user_save in modules/
user/ user.module - Save changes to a user account or add a new user.
- user_set_authmaps in modules/
user/ user.module - Save mappings of which external authentication module(s) authenticated a user. Maps external usernames to user ids in the users table.
- variable_del in includes/
bootstrap.inc - Unsets a persistent variable.
- _batch_finished in includes/
batch.inc - Ends the batch processing.
- _block_rehash in modules/
block/ block.module - Updates the 'block' DB table with the blocks currently exported by modules.
- _drupal_session_destroy in includes/
session.inc - Session handler assigned by session_set_save_handler().
- _drupal_session_garbage_collection in includes/
session.inc - Session handler assigned by session_set_save_handler().
- _locale_import_one_string_db in includes/
locale.inc - Import one string into the database.
- _menu_delete_item in includes/
menu.inc - Helper function for menu_link_delete; deletes a single menu link.
- _registry_parse_files in includes/
registry.inc - Parse all files that have changed since the registry was last built, and save their function and class listings.
- _registry_update in includes/
registry.inc - Does the work for registry_update().
- _tracker_remove in modules/
tracker/ tracker.module - Clean up indexed data when nodes or comments are removed.
- _update_7000_field_delete_field in modules/
field/ field.install - Utility function: delete a field stored in SQL storage directly from the database.
- _update_7000_field_delete_instance in modules/
field/ field.install - Utility function: delete an instance and all its data of a field stored in SQL Storage.
- _update_7000_field_sql_storage_write in modules/
field/ modules/ field_sql_storage/ field_sql_storage.install - Utility function: write field data directly to SQL storage.
- _update_authorize_clear_update_status in modules/
update/ update.authorize.inc - Private helper function to clear cached available update status data.
- _update_cache_clear in modules/
update/ update.module - Invalidates cached data relating to update status.
File
- includes/
database/ database.inc, line 2448 - Core systems for the database layer.
Code
<?php
function db_delete($table, array $options = array()) {
if (empty($options['target']) || $options['target'] == 'slave') {
$options['target'] = 'default';
}
return Database::getConnection($options['target'])->delete($table, $options);
}
?> Login or register to post comments
Comments
Example #1
Simple example taken from http://drupal.org/node/310081
<?php
// Drupal 7
$nid = 5;
$num_deleted = db_delete('node')
->condition('nid', $nid)
->execute();
// Above example is equivalent to the following in Drupal 6
$nid = 5;
db_query("DELETE FROM {node} WHERE nid = %d", $nid);
?>
Example #2
Another simple example, but with two conditional clauses, based on the Conditional clauses documentation at http://drupal.org/node/310086
<?php
$and = db_and()->condition('mid', 1)->condition('cache_type', 'year');
db_delete('mid_cache_index')->condition($and)->execute();
// Above translates to:
DELETE FROM {mid_cache_index} WHERE ( (mid = 1) AND (cache_type = 'year') )
?>
Improved Example #2
I believe It's better to write this way instead of adding
db_and()in this case. Fix me if I'm wrong.<?phpdb_delete('mid_cache_index')
->condition('mid', 1)
->condition('cache_type', 'year')
->execute();
?>