function Delete::__toString

Same name and namespace in other branches
  1. 9 core/lib/Drupal/Core/Database/Query/Delete.php \Drupal\Core\Database\Query\Delete::__toString()
  2. 8.9.x core/lib/Drupal/Core/Database/Query/Delete.php \Drupal\Core\Database\Query\Delete::__toString()
  3. 10 core/lib/Drupal/Core/Database/Query/Delete.php \Drupal\Core\Database\Query\Delete::__toString()

Implements PHP magic __toString method to convert the query to a string.

Return value

string The prepared statement.

Overrides Query::__toString

File

core/lib/Drupal/Core/Database/Query/Delete.php, line 69

Class

Delete
General class for an abstracted DELETE operation.

Namespace

Drupal\Core\Database\Query

Code

public function __toString() {
    // Create a sanitized comment string to prepend to the query.
    $comments = $this->connection
        ->makeComment($this->comments);
    $query = $comments . 'DELETE FROM {' . $this->connection
        ->escapeTable($this->table) . '} ';
    if (count($this->condition)) {
        $this->condition
            ->compile($this->connection, $this);
        $query .= "\nWHERE " . $this->condition;
    }
    return $query;
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.