array($this, 'getClauseDeleteFrom'), 'DELETE' => array($this, 'getClauseDelete'), 'FROM' => null, 'JOIN' => array($this, 'getClauseJoin'), 'WHERE' => ' AND ', 'ORDER BY' => ', ', 'LIMIT' => null, ); parent::__construct($fluent, $clauses); $this->statements['DELETE FROM'] = $table; $this->statements['DELETE'] = $table; } /** * Forces delete operation to fail silently * * @return Delete */ public function ignore() { $this->ignore = true; return $this; } /** * @return string */ protected function buildQuery() { if ($this->statements['FROM']) { unset($this->clauses['DELETE FROM']); } else { unset($this->clauses['DELETE']); } return parent::buildQuery(); } /** * Execute DELETE query * * @return bool */ public function execute() { $result = parent::execute(); if ($result) { return $result->rowCount(); } return false; } /** * @return string */ protected function getClauseDelete() { return 'DELETE' . ($this->ignore ? " IGNORE" : '') . ' ' . $this->statements['DELETE']; } /** * @return string */ protected function getClauseDeleteFrom() { return 'DELETE' . ($this->ignore ? " IGNORE" : '') . ' FROM ' . $this->statements['DELETE FROM']; } }