Example #1
0
 public function close()
 {
     if ($this->clearEntitiesOnBatch) {
         $em = $this->query->getEntityManager();
         foreach ($this->clearEntitiesOnBatch as $e) {
             $em->clear($e);
         }
     }
     $this->query = null;
     $this->results = null;
 }
 /**
  * {@inheritdoc}
  */
 public function current()
 {
     $current = $this->iterator->current();
     $data = array();
     foreach ($this->propertyPaths as $name => $propertyPath) {
         try {
             $data[$name] = $this->getValue($this->propertyAccessor->getValue($current[0], $propertyPath));
         } catch (UnexpectedTypeException $e) {
             //non existent object in path will be ignored
             $data[$name] = null;
         }
     }
     $this->query->getEntityManager()->getUnitOfWork()->detach($current[0]);
     return $data;
 }
 /**
  * Constructor.
  *
  * Stores various parameters that are otherwise unavailable
  * because Doctrine\ORM\Query\SqlWalker keeps everything private without
  * accessors.
  *
  * @param \Doctrine\ORM\Query              $query
  * @param \Doctrine\ORM\Query\ParserResult $parserResult
  * @param array                            $queryComponents
  */
 public function __construct($query, $parserResult, array $queryComponents)
 {
     $this->platform = $query->getEntityManager()->getConnection()->getDatabasePlatform();
     $this->rsm = $parserResult->getResultSetMapping();
     $this->queryComponents = $queryComponents;
     parent::__construct($query, $parserResult, $queryComponents);
 }
 /**
  * Constructor.
  *
  * Stores various parameters that are otherwise unavailable
  * because Doctrine\ORM\Query\SqlWalker keeps everything private without
  * accessors.
  *
  * @param \Doctrine\ORM\Query              $query
  * @param \Doctrine\ORM\Query\ParserResult $parserResult
  * @param array                            $queryComponents
  */
 public function __construct($query, $parserResult, array $queryComponents)
 {
     $this->platform = $query->getEntityManager()->getConnection()->getDatabasePlatform();
     $this->rsm = $parserResult->getResultSetMapping();
     $this->queryComponents = $queryComponents;
     // Reset limit and offset
     $this->firstResult = $query->getFirstResult();
     $this->maxResults = $query->getMaxResults();
     $query->setFirstResult(null)->setMaxResults(null);
     parent::__construct($query, $parserResult, $queryComponents);
 }
 /**
  * Creates a new query parser object.
  *
  * @param Query $query The Query to parse.
  */
 public function __construct(Query $query)
 {
     $this->query = $query;
     $this->em = $query->getEntityManager();
     $this->lexer = new Lexer($query->getDql());
     $this->parserResult = new ParserResult();
 }
Example #6
0
 /**
  * Resolve DQL alias into class metadata
  *
  * @param  Doctrine\ORM\Query $query
  * @param  string             $alias
  * @return array              | null
  */
 protected function getEntityFromAlias($query, $alias = null)
 {
     $em = $query->getEntityManager();
     $ast = $query->getAST();
     $fromClause = $ast->fromClause;
     foreach ($fromClause->identificationVariableDeclarations as $root) {
         $className = $root->rangeVariableDeclaration->abstractSchemaName;
         $classAlias = $root->rangeVariableDeclaration->aliasIdentificationVariable;
         if ($classAlias == $alias || null === $alias) {
             return array('alias' => $classAlias, 'metadata' => $em->getClassMetadata($className));
         } else {
             foreach ($root->joins as $join) {
                 $joinAlias = $join->joinAssociationDeclaration->aliasIdentificationVariable;
                 $joinField = $join->joinAssociationDeclaration->joinAssociationPathExpression->associationField;
                 $joinParent = $join->joinAssociationDeclaration->joinAssociationPathExpression->identificationVariable;
                 if ($joinAlias == $alias) {
                     if ($joinParent != $classAlias) {
                         $data = $this->getEntityFromAlias($query, $joinParent);
                         $metadata = $data['metadata'];
                     } else {
                         $metadata = $em->getClassMetadata($className);
                     }
                     $joinName = $metadata->associationMappings[$joinField]['targetEntity'];
                     return array('alias' => $joinAlias, 'metadata' => $em->getClassMetadata($joinName));
                 }
             }
         }
     }
     return null;
 }
Example #7
0
 /**
  * Add conditions to query.
  *
  * @access    public
  * @param    mixed $mPredicates The restriction predicates.
  * @return    DB
  * @since     1.0.0-alpha
  * @version   1.0.0-alpha
  */
 public function where($mPredicates)
 {
     $this->oQuery->getEntityManager()->createQueryBuilder()->where($mPredicates);
     return $this;
 }
Example #8
0
 /**
  * Creates a new query parser object.
  *
  * @param Query $query The Query to parse.
  */
 public function __construct(Query $query)
 {
     $this->_query = $query;
     $this->_em = $query->getEntityManager();
     $this->_lexer = new Lexer($query->getDql());
     $this->_parserResult = new ParserResult();
     //$this->_parserResult->setEntityManager($this->_em);
 }
 /**
  * Constructor.
  *
  * @param DqlQuery                 $query           Doctrine ORM Query object
  * @param SearchConditionInterface $searchCondition SearchCondition object
  *
  * @throws BadMethodCallException When SearchCondition contains errors
  */
 public function __construct(DqlQuery $query, SearchConditionInterface $searchCondition)
 {
     parent::__construct($searchCondition, $query->getEntityManager());
     $this->query = $query;
 }