Creates a DELETE Statement

@param  Node\DeleteStatement
@return string
971156
protected function visitSirelNodeDeleteStatement(Node\DeleteStatement $delete)
    {
        $query = join(' ', array_filter(array(
            "DELETE FROM " . $this->visit($delete->relation),

            // WHERE
            ($delete->restrictions
                ? "WHERE " . join(" AND ", $this->visitEach($delete->restrictions))
                : null
            ),

            // ORDER BY
            ($delete->orders
                ? "ORDER BY " . join(", ", $this->visitEach($delete->orders))
                : null)
        )));

        $query = $this->platform->modifyLimitQuery($query, $delete->limit->getExpression(), $delete->offset->getExpression());
        $query .= ';';

        return $query;
    }
941922
public function delete()
    {
        // convert to condition.
        $args = func_get_args();
        $cond = call_user_func_array(array($this, 'toCondition'), $args);

        // to SQL.
        $sql = $cond->toDeleteSQL();
        var_dump($sql, $cond->getParams());

        // query.
        $sth = $this->query($sql, $cond->getParams());
        return $sth->isSuccess();
    }
251061
public function getDeleteSql(array $sql)
    {
        $delete = 'DELETE';
        if (!empty($this->priority)) {
            $delete .= ' ' . $this->priority;
        }
        if (!empty($this->quick)) {
            $delete .= ' ' . $this->quick;
        }
        if (!empty($this->ignore)) {
            $delete .= ' ' . $this->ignore;
        }
        $sql[] = $delete . ' FROM ' . $this->quoter->quoteName($this->table);

        return $sql;
    }
456368
public function select(SQLStatement $select): string
    {
        $sql = $select->getDistinct() ? 'SELECT DISTINCT ' : 'SELECT ';
        $sql .= $this->handleColumns($select->getColumns());
        $sql .= $this->handleInto($select->getIntoTable(), $select->getIntoDatabase());
        $sql .= ' FROM ';
        $sql .= $this->handleTables($select->getTables());
        $sql .= $this->handleJoins($select->getJoins());
        $sql .= $this->handleWheres($select->getWheres());
        $sql .= $this->handleGroupings($select->getGroupBy());
        $sql .= $this->handleOrderings($select->getOrder());
        $sql .= $this->handleHavings($select->getHaving());
        $sql .= $this->handleOffset($select->getOffset(), $select->getLimit());
        $sql .= $this->handleLimit($select->getLimit(), $select->getOffset());

        return $sql;
    }
901345
public function toDeleteSQL()
    {
        $sql = [];
        $this->params = [];
        
        $sql[] = sprintf('DELETE FROM %s', $this->table->getTableName());
        $sql[] = $this->where->toSQL();
        $this->bind($this->where->getParams());

        return join(' ', $sql);
    }
362075
public function delete()
    {
        // Define wheres
        $where = $this->getWhereString();

        // Define where in
        $whereIn = $this->getWhereInString();

        // Build query
        $this->query = 'DELETE FROM ' . $this->table . ' '. $where . ' ' . $whereIn;

        // Prepare statement
        $this->statement = $this->pdo->prepare($this->query);

        // Bind where values
        if (count($this->wheres)) {
            $this->bindWheres();
        }

        // Execute statement
        $result = $this->statement->execute();

        // Reset values
        $this->reset();

        // Return result
        return $result;
    }
934467
private function getDeleteQuery()
    {
        $fromClause = null;

        if (isset($this->parts['from'][0]['alias'])) {
            $fromClause = $this->parts['from'][0]['alias'].' ';
        }

        $fromClause .= 'FROM '.$this->getFromClause();

        return 'DELETE '.$fromClause.
               (($this->parts['where'] !== null) ? ' WHERE '.$this->parts['where'] : null);
    }
444295
private function echoTagStatement() {
    $node = new EchoTagStatementNode();
    $this->mustMatch(T_OPEN_TAG_WITH_ECHO, $node);
    $expressions = new CommaListNode();
    do {
      $expressions->addChild($this->expr());
    } while ($this->tryMatch(',', $expressions));
    $node->addChild($expressions, 'expressions');
    $this->tryMatch(';', $node);
    $this->mustMatch(T_CLOSE_TAG, $node, NULL, TRUE);
    return $node;
  }
908136
protected function buildDeleteQuery(SQLDelete $query, array &$parameters)
    {
        $sql  = $this->buildDeleteFragment($query, $parameters);
        $sql .= $this->buildFromFragment($query, $parameters);
        $sql .= $this->buildWhereFragment($query, $parameters);
        return $sql;
    }
795791
public function delete()
    {
        if ($this->beforeDelete()) {
            if (is_array($this->_pk)) {
                $c = $p = [];
                foreach ($this->_originalPk as $k => $v) {
                    $c[] = "`$k` = :pk_$k";
                    $p[":pk_$k"] = $v;
                }
                $r = (bool)$this->_db->table($this->_tableName)
                    ->where(implode(" AND ", $c), $p)
                    ->delete();
            } else {
                $r = (bool)$this->_db->table($this->_tableName)
                    ->where("`{$this->_pk}` = :__pk")->setParam(':__pk', $this->_originalPk)
                    ->delete();
            }

            if ($r) {
                return $this->afterDelete();
            }
        }
    }
1068321
public static function statement($sqlstatement)
    {
        static::verifyConnection();

        if (!preg_match(
            "/^((drop|alter|create)\s+(?:(?:temp|temporary)\s+)?table|truncate|call)(\s+)?(.+?);?$/i",
            $sqlstatement
        )) {
            throw new DatabaseException(
                'Syntax Error on the Request',
                E_USER_ERROR
            );
        }

        return static::$adapter
            ->getConnection()
            ->exec($sqlstatement) === 0;
    }
569072
public function delete()
    {
        if ($this->getPk() === null) {
            return false;
        }
        $query = $this->_queryClass;
        $bindKey = PdoBindHelper::generateBindKey();
        $result = DbConnector::getAdapter()->delete((new $query)->getTableName(), $this->_pkWhere($bindKey), [$bindKey => $this->getInitialStateValue('id')]);
        return ($result > 0) ? true : false;
    }
1106707
public function delete()
    {
        $sql = 'delete from `' . $this->table . '`';

        if (!is_null($this->where)) {
            $sql .= ' where ' . $this->where;

            $this->where = null;
        }

        $stmt = $this->connection->prepare($sql);

        $this->bind($stmt, $this->where_data_binding);

        $this->where_data_binding = [];

        $stmt->execute();

        $r = $stmt->rowCount();

        return (int) $r;
    }
848913
public function toString()
    {
        if (!$this->_parts['table']) {
            throw new SqlException("Invalid `TRUNCATE` statement, missing `TABLE` clause.");
        }

        return 'DELETE' . $this->_buildClause('FROM', $this->dialect()->names($this->_parts['table'])) . ';' .
            'DELETE' . $this->_buildClause('FROM', $this->dialect()->names('SQLITE_SEQUENCE')) .
                ' WHERE name=' . $this->dialect()->names($this->_parts['table']);
    }
305446
public function getDeleteSQL()
        {
            if (!$this->query->getTable() instanceof Table) {
                throw new Exception('Trying to generate sql when no table is being used.');
            }
            $sql = 'DELETE FROM ' . $this->getTable()->getSqlTableName();
            $sql .= $this->generateWhereSQL(true);

            return $sql;
        }
706090
public function delete()
    {
        $this->brokenOnDelete = true;
        $this->onBeforeDelete();
        if ($this->brokenOnDelete) {
            user_error(static::class . " has a broken onBeforeDelete() function."
                . " Make sure that you call parent::onBeforeDelete().", E_USER_ERROR);
        }

        // Deleting a record without an ID shouldn't do anything
        if (!$this->ID) {
            throw new LogicException("DataObject::delete() called on a DataObject without an ID");
        }

        // TODO: This is quite ugly.  To improve:
        //  - move the details of the delete code in the DataQuery system
        //  - update the code to just delete the base table, and rely on cascading deletes in the DB to do the rest
        //    obviously, that means getting requireTable() to configure cascading deletes ;-)
        $srcQuery = DataList::create(static::class)
            ->filter('ID', $this->ID)
            ->dataQuery()
            ->query();
        $queriedTables = $srcQuery->queriedTables();
        $this->extend('updateDeleteTables', $queriedTables, $srcQuery);
        foreach ($queriedTables as $table) {
            $delete = SQLDelete::create("\"$table\"", array('"ID"' => $this->ID));
            $this->extend('updateDeleteTable', $delete, $table, $queriedTables, $srcQuery);
            $delete->execute();
        }
        // Remove this item out of any caches
        $this->flushCache();

        $this->onAfterDelete();

        $this->OldID = $this->ID;
        $this->ID = 0;
    }
1313132
public function generateDeleteSQL()
        {
            if ($this->sql === null) {
                $this->detectDistinct();
                $this->action = QueryInterface::ACTION_DELETE;
                $sql_generator = new SqlGenerator($this);

                $this->sql = $sql_generator->getDeleteSQL();
            }

            return $this->sql;
        }