WordPress как на ладони
Недорогой хостинг для сайтов на WordPress: wordpress.jino.ru Самая быстрая Тема-конструктор для WordPress
функция не описана

wpdb::delete() public WP 3.4.0

Deletes a row in the table.


wpdb::delete( 'table', array( 'ID' => 1 ) )
wpdb::delete( 'table', array( 'ID' => 1 ), array( '%d' ) )

{} Это метод класса: wpdb{}

Хуков нет.


Число/false. The number of rows updated, or false on error.


global $wpdb;
$wpdb->delete( $table, $where, $where_format );
$table(строка) (обязательный)
Table name.
$where(массив) (обязательный)
A named array of WHERE clauses (in column => value pairs). Multiple clauses will be joined with ANDs. Both $where columns and $where values should be "raw". Sending a null value will create an IS NULL comparison - the corresponding format will be ignored in this case.
An array of formats to be mapped to each of the values in $where. If string, that format will be used for all of the items in $where. A format is one of '%d', '%f', '%s' (integer, float, string). If omitted, all values in $data will be treated as strings unless otherwise specified in wpdb::$field_types.
По умолчанию: null


  • Смотрите: wpdb::prepare()
  • Смотрите: wpdb::$field_types
  • Смотрите: wp_set_wpdb_vars()

Список изменений

С версии 3.4.0 Введена.

Код wpdb::delete() WP 5.5.1

public function delete( $table, $where, $where_format = null ) {
	if ( ! is_array( $where ) ) {
		return false;

	$where = $this->process_fields( $table, $where, $where_format );
	if ( false === $where ) {
		return false;

	$conditions = array();
	$values     = array();
	foreach ( $where as $field => $value ) {
		if ( is_null( $value['value'] ) ) {
			$conditions[] = "`$field` IS NULL";

		$conditions[] = "`$field` = " . $value['format'];
		$values[]     = $value['value'];

	$conditions = implode( ' AND ', $conditions );

	$sql = "DELETE FROM `$table` WHERE $conditions";

	$this->check_current_query = false;
	return $this->query( $this->prepare( $sql, $values ) );