function DeleteQuery::__toString

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

Return value

string The prepared statement.

Overrides Query::__toString

File

includes/database/query.inc, line 867

Class

DeleteQuery
General class for an abstracted DELETE operation.

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)) {
        try {
            $this->condition
                ->compile($this->connection, $this);
        } catch (InvalidQueryConditionOperatorException $e) {
            drupal_trigger_fatal_error($e->getMessage());
        }
        $query .= "\nWHERE " . $this->condition;
    }
    return $query;
}

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