3 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
4 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
5 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
6 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
7 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
8 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
9 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
10 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
11 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
12 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
13 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
15 * This software consists of voluntary contributions made by many individuals
16 * and is licensed under the MIT license. For more information, see
17 * <http://www.doctrine-project.org>.
20 namespace Doctrine\ORM;
23 * Represents a native SQL query.
25 * @author Roman Borschel <roman@code-factory.org>
28 final class NativeQuery extends AbstractQuery
33 * Sets the SQL of the query.
36 * @return NativeQuery This query instance.
38 public function setSQL($sql)
48 * @return mixed The built SQL query or an array of all SQL queries.
51 public function getSQL()
59 protected function _doExecute()
61 $parameters = array();
64 foreach ($this->getParameters() as $parameter) {
65 $name = $parameter->getName();
66 $value = $this->processParameterValue($parameter->getValue());
67 $type = ($parameter->getValue() === $value)
68 ? $parameter->getType()
69 : Query\ParameterTypeInferer::inferType($value);
71 $parameters[$name] = $value;
72 $types[$name] = $type;
75 if ($parameters && is_int(key($parameters))) {
79 $parameters = array_values($parameters);
80 $types = array_values($types);
83 return $this->_em->getConnection()->executeQuery(
84 $this->_sql, $parameters, $types, $this->_queryCacheProfile