Permalink
Browse files

Merge pull request #422 from FabioBatSilva/DDC-1574

DDC-1574 - "new" operator
  • Loading branch information...
2 parents 91caff1 + dd984c7 commit 13762f20c9f6daa0c2e4e8a113de01969c6621da @beberlei beberlei committed Oct 5, 2012
@@ -234,6 +234,25 @@ protected function gatherRowData(array $data, array &$cache, array &$id, array &
// maybe from an additional column that has not been defined in a NativeQuery ResultSetMapping.
continue 2;
}
+
+ if (isset($this->_rsm->newObjectMappings[$key])) {
+ $mapping = $this->_rsm->newObjectMappings[$key];
+
+ $cache[$key]['isNewObjectParameter'] = true;
+ $cache[$key]['argIndex'] = $mapping['argIndex'];
+ $cache[$key]['objIndex'] = $mapping['objIndex'];
+ $cache[$key]['class'] = new \ReflectionClass($mapping['className']);
+ }
+ }
+
+ if (isset($cache[$key]['isNewObjectParameter'])) {
+ $class = $cache[$key]['class'];
+ $argIndex = $cache[$key]['argIndex'];
+ $objIndex = $cache[$key]['objIndex'];
+ $value = $cache[$key]['type']->convertToPHPValue($value, $this->_platform);
+
+ $rowData['newObjects'][$objIndex]['class'] = $class;
+ $rowData['newObjects'][$objIndex]['args'][$argIndex] = $value;
}
if (isset($cache[$key]['isScalar'])) {
Oops, something went wrong.
@@ -0,0 +1,60 @@
+<?php
+/*
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+ * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+ * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ * This software consists of voluntary contributions made by many individuals
+ * and is licensed under the LGPL. For more information, see
+ * <http://www.doctrine-project.org>.
+ */
+
+namespace Doctrine\ORM\Query\AST;
+
+/**
+ * NewObjectExpression ::= "NEW" IdentificationVariable "(" NewObjectArg {"," NewObjectArg}* ")"
+ *
+ * @license http://www.opensource.org/licenses/lgpl-license.php LGPL
+ * @link www.doctrine-project.org
+ * @since 2.3
+ * @author Fabio B. Silva <fabio.bat.silva@gmail.com>
+ */
+class NewObjectExpression extends Node
+{
+ /**
+ * @var string
+ */
+ public $className;
+
+ /**
+ * @var array
+ */
+ public $args;
+
+ /**
+ * @param type $className
+ * @param array $args
+ */
+ public function __construct($className, array $args)
+ {
+ $this->className = $className;
+ $this->args = $args;
+ }
+
+ /**
+ * @param \Doctrine\ORM\Query\SqlWalker $sqlWalker
+ * @return string
+ */
+ public function dispatch($sqlWalker)
+ {
+ return $sqlWalker->walkNewObject($this);
+ }
+}
@@ -108,6 +108,7 @@ class Lexer extends \Doctrine\Common\Lexer
const T_WHERE = 154;
const T_WITH = 155;
const T_PARTIAL = 156;
+ const T_NEW = 157;
/**
* Creates a new query scanner object.
Oops, something went wrong.

0 comments on commit 13762f2

Please sign in to comment.