Rajout de doctrine/orm
[zf2.biz/galerie.git] / vendor / doctrine / orm / lib / Doctrine / ORM / Query / ParserResult.php
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 MIT license. For more information, see
17  * <http://www.doctrine-project.org>.
18  */
19
20 namespace Doctrine\ORM\Query;
21
22 /**
23  * Encapsulates the resulting components from a DQL query parsing process that
24  * can be serialized.
25  *
26  * @author      Guilherme Blanco <guilhermeblanco@hotmail.com>
27  * @author      Janne Vanhala <jpvanhal@cc.hut.fi>
28  * @author              Roman Borschel <roman@code-factory.org>
29  * @license     http://www.opensource.org/licenses/lgpl-license.php LGPL
30  * @link        http://www.doctrine-project.org
31  * @since       2.0
32  */
33 class ParserResult
34 {
35     /**
36      * The SQL executor used for executing the SQL.
37      *
38      * @var \Doctrine\ORM\Query\Exec\AbstractSqlExecutor
39      */
40     private $_sqlExecutor;
41
42     /**
43      * The ResultSetMapping that describes how to map the SQL result set.
44      *
45      * @var \Doctrine\ORM\Query\ResultSetMapping
46      */
47     private $_resultSetMapping;
48
49     /**
50      * The mappings of DQL parameter names/positions to SQL parameter positions.
51      *
52      * @var array
53      */
54     private $_parameterMappings = array();
55
56     /**
57      * Initializes a new instance of the <tt>ParserResult</tt> class.
58      * The new instance is initialized with an empty <tt>ResultSetMapping</tt>.
59      */
60     public function __construct()
61     {
62         $this->_resultSetMapping = new ResultSetMapping;
63     }
64
65     /**
66      * Gets the ResultSetMapping for the parsed query.
67      *
68      * @return ResultSetMapping The result set mapping of the parsed query or NULL
69      *                          if the query is not a SELECT query.
70      */
71     public function getResultSetMapping()
72     {
73         return $this->_resultSetMapping;
74     }
75
76     /**
77      * Sets the ResultSetMapping of the parsed query.
78      *
79      * @param ResultSetMapping $rsm
80      */
81     public function setResultSetMapping(ResultSetMapping $rsm)
82     {
83         $this->_resultSetMapping = $rsm;
84     }
85
86     /**
87      * Sets the SQL executor that should be used for this ParserResult.
88      *
89      * @param \Doctrine\ORM\Query\Exec\AbstractSqlExecutor $executor
90      */
91     public function setSqlExecutor($executor)
92     {
93         $this->_sqlExecutor = $executor;
94     }
95
96     /**
97      * Gets the SQL executor used by this ParserResult.
98      *
99      * @return \Doctrine\ORM\Query\Exec\AbstractSqlExecutor
100      */
101     public function getSqlExecutor()
102     {
103         return $this->_sqlExecutor;
104     }
105
106     /**
107      * Adds a DQL to SQL parameter mapping. One DQL parameter name/position can map to
108      * several SQL parameter positions.
109      *
110      * @param string|integer $dqlPosition
111      * @param integer $sqlPosition
112      */
113     public function addParameterMapping($dqlPosition, $sqlPosition)
114     {
115         $this->_parameterMappings[$dqlPosition][] = $sqlPosition;
116     }
117
118     /**
119      * Gets all DQL to SQL parameter mappings.
120      *
121      * @return array The parameter mappings.
122      */
123     public function getParameterMappings()
124     {
125         return $this->_parameterMappings;
126     }
127
128     /**
129      * Gets the SQL parameter positions for a DQL parameter name/position.
130      *
131      * @param string|integer $dqlPosition The name or position of the DQL parameter.
132      * @return array The positions of the corresponding SQL parameters.
133      */
134     public function getSqlParameterPositions($dqlPosition)
135     {
136         return $this->_parameterMappings[$dqlPosition];
137     }
138 }