function drush_db_delete
| 6.x dbtng.inc | drush_db_delete($table, $where = NULL, $args = NULL) |
| 5.x dbtng.inc | drush_db_delete($table, $where = NULL, $args = NULL) |
| 3.x drush.inc | drush_db_delete($table, $where = NULL, $args = NULL) |
| 4.x drush.inc | drush_db_delete($table, $where = NULL, $args = NULL) |
A db_delete() that works for any version of Drupal.
Parameters
$table: String. The table to operate on.
$where: String. WHERE snippet for the operation. It uses named placeholders. see @_drush_replace_query_placeholders()
$args: Array. Arguments for the WHERE snippet.
Return value
Affected rows (except on D7+mysql without a WHERE clause - returns TRUE) or FALSE.
Related topics
2 calls to drush_db_delete()
- drush_cache_clear_theme_registry in commands/
core/ cache.drush.inc - drush_core_watchdog_delete in commands/
core/ watchdog.drush.inc - Command callback.
File
- includes/
dbtng.inc, line 138
Code
function drush_db_delete($table, $where = NULL, $args = NULL) {
if (drush_drupal_major_version() >= 7) {
if (!empty($where)) {
$query = db_delete($table)->where($where, $args);
return $query->execute();
}
else {
return db_truncate($table)->execute();
}
}
else {
$query = "DELETE FROM {{$table}}";
if (!empty($where)) {
$where = _drush_replace_query_placeholders($where, $args);
$query .= ' WHERE ' . $where;
}
if (!db_query($query, $args)) {
return FALSE;
}
return db_affected_rows();
}
}