Rajout de doctrine/orm
[zf2.biz/galerie.git] / vendor / doctrine / orm / lib / Doctrine / ORM / Persisters / SqlValueVisitor.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\Persisters;
21
22 use Doctrine\Common\Collections\Expr\ExpressionVisitor;
23 use Doctrine\Common\Collections\Expr\Comparison;
24 use Doctrine\Common\Collections\Expr\Value;
25 use Doctrine\Common\Collections\Expr\CompositeExpression;
26
27 use Doctrine\ORM\Mapping\ClassMetadata;
28
29 use Doctrine\DBAL\Types\Type;
30 use Doctrine\DBAL\Connection;
31
32 /**
33  * Extract the values from a criteria/expression
34  *
35  * @author Benjamin Eberlei <kontakt@beberlei.de>
36  */
37 class SqlValueVisitor extends ExpressionVisitor
38 {
39     /**
40      * @var array
41      */
42     private $values = array();
43
44     /**
45      * @var array
46      */
47     private $types  = array();
48
49     /**
50      * Convert a comparison expression into the target query language output
51      *
52      * @param \Doctrine\Common\Collections\Expr\Comparison $comparison
53      *
54      * @return mixed
55      */
56     public function walkComparison(Comparison $comparison)
57     {
58         $value          = $comparison->getValue()->getValue();
59         $field          = $comparison->getField();
60         
61         $this->values[] = $value;
62         $this->types[]  = array($field, $value);
63     }
64
65     /**
66      * Convert a composite expression into the target query language output
67      *
68      * @param \Doctrine\Common\Collections\Expr\CompositeExpression $expr
69      *
70      * @return mixed
71      */
72     public function walkCompositeExpression(CompositeExpression $expr)
73     {
74         foreach ($expr->getExpressionList() as $child) {
75             $this->dispatch($child);
76         }
77     }
78
79     /**
80      * Convert a value expression into the target query language part.
81      *
82      * @param \Doctrine\Common\Collections\Expr\Value $value
83      *
84      * @return mixed
85      */
86     public function walkValue(Value $value)
87     {
88         return;
89     }
90
91     /**
92      * Return the Parameters and Types necessary for matching the last visited expression.
93      *
94      * @return array
95      */
96     public function getParamsAndTypes()
97     {
98         return array($this->values, $this->types);
99     }
100 }