. */ namespace Doctrine\ORM; /** * Represents a native SQL query. * * @author Roman Borschel * @since 2.0 */ final class NativeQuery extends AbstractQuery { private $_sql; /** * Sets the SQL of the query. * * @param string $sql * @return NativeQuery This query instance. */ public function setSQL($sql) { $this->_sql = $sql; return $this; } /** * Gets the SQL query. * * @return mixed The built SQL query or an array of all SQL queries. * @override */ public function getSQL() { return $this->_sql; } /** * {@inheritdoc} */ protected function _doExecute() { $stmt = $this->_em->getConnection()->prepare($this->_sql); $params = $this->_params; foreach ($params as $key => $value) { if (isset($this->_paramTypes[$key])) { $stmt->bindValue($key, $value, $this->_paramTypes[$key]); } else { $stmt->bindValue($key, $value); } } $stmt->execute(); return $stmt; } }