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

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

collaborator page

File size: 4.2 KB
Line 
1<?php
2/*
3 *  $Id$
4 *
5 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
6 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
7 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
8 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
9 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
10 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
11 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
12 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
13 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
14 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
15 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
16 *
17 * This software consists of voluntary contributions made by many individuals
18 * and is licensed under the LGPL. For more information, see
19 * <http://www.doctrine-project.org>.
20 */
21
22namespace Doctrine\ORM\Query;
23
24/**
25 * Encapsulates the resulting components from a DQL query parsing process that
26 * can be serialized.
27 *
28 * @author      Guilherme Blanco <guilhermeblanco@hotmail.com>
29 * @author      Janne Vanhala <jpvanhal@cc.hut.fi>
30 * @author              Roman Borschel <roman@code-factory.org>
31 * @license     http://www.opensource.org/licenses/lgpl-license.php LGPL
32 * @link        http://www.doctrine-project.org
33 * @since       2.0
34 * @version     $Revision$
35 */
36class ParserResult
37{
38    /**
39     * The SQL executor used for executing the SQL.
40     *
41     * @var \Doctrine\ORM\Query\Exec\AbstractSqlExecutor
42     */
43    private $_sqlExecutor;
44
45    /**
46     * The ResultSetMapping that describes how to map the SQL result set.
47     *
48     * @var \Doctrine\ORM\Query\ResultSetMapping
49     */
50    private $_resultSetMapping;
51
52    /**
53     * The mappings of DQL parameter names/positions to SQL parameter positions.
54     *
55     * @var array
56     */
57    private $_parameterMappings = array();
58
59    /**
60     * Initializes a new instance of the <tt>ParserResult</tt> class.
61     * The new instance is initialized with an empty <tt>ResultSetMapping</tt>.
62     */
63    public function __construct()
64    {
65        $this->_resultSetMapping = new ResultSetMapping;
66    }
67
68    /**
69     * Gets the ResultSetMapping for the parsed query.
70     *
71     * @return ResultSetMapping The result set mapping of the parsed query or NULL
72     *                          if the query is not a SELECT query.
73     */
74    public function getResultSetMapping()
75    {
76        return $this->_resultSetMapping;
77    }
78
79    /**
80     * Sets the ResultSetMapping of the parsed query.
81     *
82     * @param ResultSetMapping $rsm
83     */
84    public function setResultSetMapping(ResultSetMapping $rsm)
85    {
86        $this->_resultSetMapping = $rsm;
87    }
88
89    /**
90     * Sets the SQL executor that should be used for this ParserResult.
91     *
92     * @param \Doctrine\ORM\Query\Exec\AbstractSqlExecutor $executor
93     */
94    public function setSqlExecutor($executor)
95    {
96        $this->_sqlExecutor = $executor;
97    }
98
99    /**
100     * Gets the SQL executor used by this ParserResult.
101     *
102     * @return \Doctrine\ORM\Query\Exec\AbstractSqlExecutor
103     */
104    public function getSqlExecutor()
105    {
106        return $this->_sqlExecutor;
107    }
108
109    /**
110     * Adds a DQL to SQL parameter mapping. One DQL parameter name/position can map to
111     * several SQL parameter positions.
112     *
113     * @param string|integer $dqlPosition
114     * @param integer $sqlPosition
115     */
116    public function addParameterMapping($dqlPosition, $sqlPosition)
117    {
118        $this->_parameterMappings[$dqlPosition][] = $sqlPosition;
119    }
120
121    /**
122     * Gets all DQL to SQL parameter mappings.
123     *
124     * @return array The parameter mappings.
125     */
126    public function getParameterMappings()
127    {
128        return $this->_parameterMappings;
129    }
130
131    /**
132     * Gets the SQL parameter positions for a DQL parameter name/position.
133     *
134     * @param string|integer $dqlPosition The name or position of the DQL parameter.
135     * @return array The positions of the corresponding SQL parameters.
136     */
137    public function getSqlParameterPositions($dqlPosition)
138    {
139        return $this->_parameterMappings[$dqlPosition];
140    }
141}
Note: See TracBrowser for help on using the repository browser.