. */ namespace Doctrine\ORM\Query\AST; /** * DeleteStatement = DeleteClause [WhereClause] * * @author Guilherme Blanco * @license http://www.opensource.org/licenses/lgpl-license.php LGPL * @link http://www.phpdoctrine.org * @since 2.0 * @version $Revision$ */ class DeleteStatement extends Node { protected $_deleteClause; protected $_whereClause; /* Setters */ public function setDeleteClause($deleteClause) { $this->_deleteClause = $deleteClause; } public function setWhereClause($whereClause) { $this->_whereClause = $whereClause; } /* Getters */ public function getDeleteClause() { return $this->_deleteClause; } public function getWhereClause() { return $this->_whereClause; } /* REMOVE ME LATER. COPIED METHODS FROM SPLIT OF PRODUCTION INTO "AST" AND "PARSER" */ public function buildSql() { // The 1=1 is needed to workaround the affected_rows in MySQL. // Simple "DELETE FROM table_name" gives 0 affected rows. return $this->_deleteClause->buildSql() . (($this->_whereClause !== null) ? ' ' . $this->_whereClause->buildSql() : ' WHERE 1 = 1'); } }