source: pro-violet-viettel/sourcecode/application/libraries/Doctrine/ORM/NativeQuery.php @ 345

Last change on this file since 345 was 345, checked in by quyenla, 11 years ago

collaborator page

File size: 2.1 KB
Line 
1<?php
2/*
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.
14 *
15 * This software consists of voluntary contributions made by many individuals
16 * and is licensed under the LGPL. For more information, see
17 * <http://www.doctrine-project.org>.
18 */
19
20namespace Doctrine\ORM;
21
22/**
23 * Represents a native SQL query.
24 *
25 * @author Roman Borschel <roman@code-factory.org>
26 * @since 2.0
27 */
28final class NativeQuery extends AbstractQuery
29{
30    private $_sql;
31
32    /**
33     * Sets the SQL of the query.
34     *
35     * @param string $sql
36     * @return NativeQuery This query instance.
37     */
38    public function setSQL($sql)
39    {
40        $this->_sql = $sql;
41
42        return $this;
43    }
44
45    /**
46     * Gets the SQL query.
47     *
48     * @return mixed The built SQL query or an array of all SQL queries.
49     * @override
50     */
51    public function getSQL()
52    {
53        return $this->_sql;
54    }
55
56    /**
57     * {@inheritdoc}
58     */
59    protected function _doExecute()
60    {
61        $params = $this->_params;
62        $types  = $this->_paramTypes;
63
64        if ($params && is_int(key($params))) {
65            ksort($params);
66            ksort($types);
67
68            $params = array_values($params);
69            $types  = array_values($types);
70        }
71
72        return $this->_em->getConnection()->executeQuery(
73            $this->_sql, $params, $types, $this->_queryCacheProfile
74        );
75    }
76}
Note: See TracBrowser for help on using the repository browser.