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.
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>.
20 namespace Doctrine\ORM\Persisters;
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;
27 use Doctrine\ORM\Mapping\ClassMetadata;
29 use Doctrine\DBAL\Types\Type;
30 use Doctrine\DBAL\Connection;
33 * Extract the values from a criteria/expression
35 * @author Benjamin Eberlei <kontakt@beberlei.de>
37 class SqlValueVisitor extends ExpressionVisitor
42 private $values = array();
47 private $types = array();
50 * Convert a comparison expression into the target query language output
52 * @param \Doctrine\Common\Collections\Expr\Comparison $comparison
56 public function walkComparison(Comparison $comparison)
58 $value = $comparison->getValue()->getValue();
59 $field = $comparison->getField();
61 $this->values[] = $value;
62 $this->types[] = array($field, $value);
66 * Convert a composite expression into the target query language output
68 * @param \Doctrine\Common\Collections\Expr\CompositeExpression $expr
72 public function walkCompositeExpression(CompositeExpression $expr)
74 foreach ($expr->getExpressionList() as $child) {
75 $this->dispatch($child);
80 * Convert a value expression into the target query language part.
82 * @param \Doctrine\Common\Collections\Expr\Value $value
86 public function walkValue(Value $value)
92 * Return the Parameters and Types necessary for matching the last visited expression.
96 public function getParamsAndTypes()
98 return array($this->values, $this->types);