Rajout de doctrine/orm
[zf2.biz/galerie.git] / vendor / doctrine / orm / lib / Doctrine / ORM / Query / Expr / Join.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\Expr;
21
22 /**
23  * Expression class for DQL from
24  *
25  * 
26  * @link    www.doctrine-project.org
27  * @since   2.0
28  * @author  Guilherme Blanco <guilhermeblanco@hotmail.com>
29  * @author  Jonathan Wage <jonwage@gmail.com>
30  * @author  Roman Borschel <roman@code-factory.org>
31  */
32 class Join
33 {
34     const INNER_JOIN    = 'INNER';
35     const LEFT_JOIN     = 'LEFT';
36
37     const ON            = 'ON';
38     const WITH          = 'WITH';
39
40     /**
41      * @var string
42      */
43     protected $joinType;
44
45     /**
46      * @var string
47      */
48     protected $join;
49
50     /**
51      * @var string
52      */
53     protected $alias;
54
55     /**
56      * @var string
57      */
58     protected $conditionType;
59
60     /**
61      * @var string
62      */
63     protected $condition;
64
65     /**
66      * @var string
67      */
68     protected $indexBy;
69
70     /**
71      * @param string $joinType      The condition type constant. Either INNER_JOIN or LEFT_JOIN.
72      * @param string $join          The relationship to join
73      * @param string $alias         The alias of the join
74      * @param string $conditionType The condition type constant. Either ON or WITH.
75      * @param string $condition     The condition for the join
76      * @param string $indexBy       The index for the join
77      */
78     public function __construct($joinType, $join, $alias = null, $conditionType = null, $condition = null, $indexBy = null)
79     {
80         $this->joinType       = $joinType;
81         $this->join           = $join;
82         $this->alias          = $alias;
83         $this->conditionType  = $conditionType;
84         $this->condition      = $condition;
85         $this->indexBy        = $indexBy;
86     }
87
88     /**
89      * @return string 
90      */
91     public function getJoinType()
92     {
93         return $this->joinType;
94     }
95
96     /**
97      * @return string
98      */
99     public function getJoin()
100     {
101         return $this->join;
102     }
103
104     /**
105      * @return string
106      */
107     public function getAlias()
108     {
109         return $this->alias;
110     }
111
112     /**
113      * @return string
114      */
115     public function getConditionType()
116     {
117         return $this->conditionType;
118     }
119
120     /**
121      * @return string
122      */
123     public function getCondition()
124     {
125         return $this->condition;
126     }
127
128     /**
129      * @return string
130      */
131     public function getIndexBy()
132     {
133         return $this->indexBy;
134     }
135
136
137     /**
138      * @return string
139      */
140     public function __toString()
141     {
142         return strtoupper($this->joinType) . ' JOIN ' . $this->join
143              . ($this->alias ? ' ' . $this->alias : '')
144              . ($this->condition ? ' ' . strtoupper($this->conditionType) . ' ' . $this->condition : '')
145              . ($this->indexBy ? ' INDEX BY ' . $this->indexBy : '');
146     }
147 }