public function DeleteQuery::__toString

public 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
Non-specific Database query code. Used by all engines.

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)) {

    $this->condition->compile($this->connection, $this);
    $query .= "\nWHERE " . $this->condition;
  }

  return $query;
}

© 2001–2016 by the original authors
Licensed under the GNU General Public License, version 2 and later.
Drupal is a registered trademark of Dries Buytaert.
https://api.drupal.org/api/drupal/includes!database!query.inc/function/DeleteQuery::__toString/7.x