/** * Converts EntityQuery to IExpresion object. * * Note that projections, and references to associated entities are useless and won't be * presented in the resulting expression because required joins can only be specified * as sources for selection * * @todo check whether we refer to encapsulants and avoid this * * @return IExpression */ function toExpression() { if (!$this->condition) { return new ExpressionChain(); } $eqb = new EntityQueryBuilder($this->entity); $subjected = $this->condition->toSubjected($eqb); Assert::isTrue(sizeof($eqb->getSelectQuerySources()) == 1, 'do not refer to %s encapsulants here', $this->entity->getLogicalSchema()->getEntityName()); return $subjected; }
/** * @param DB $db RDBMS to use * @param IQueryable $entity ORM-related entity representation */ function __construct(DB $db, IQueryable $entity) { $this->db = $db; $this->entity = $entity; $this->map = $entity->getMap(); $this->logicalSchema = $entity->getLogicalSchema(); $this->physicalSchema = $entity->getPhysicalSchema(); $this->identifier = $this->logicalSchema->getIdentifier(); if ($this->identifier) { $this->identityMap = new OrmIdentityMap($this->logicalSchema); } }
/** * @return EntityQueryBuilder */ function joinEncapsulant($encapsulant) { Assert::isScalar($encapsulant); if (!isset($this->joined[$encapsulant])) { $property = $this->entity->getLogicalSchema()->getProperty($encapsulant); $type = $property->getType(); Assert::isTrue($type instanceof AssociationPropertyType); $builder = $this->joined[$encapsulant] = new self($type->getContainer(), $this->alias . '_' . $encapsulant); $builder->joins = array(); $this->join($property, $type, $builder, end($this->joins)); } return $this->joined[$encapsulant]; }
function getContainerClassName(OrmProperty $property) { return $this->container->getLogicalSchema()->getEntityName() . ucfirst($property->getName()) . 'Container'; }
protected function getCtorArgumentsPhpCode() { return array($this->container->getLogicalSchema()->getEntityName() . '::orm()', 'new AssociationMultiplicity(AssociationMultiplicity::' . $this->multiplicity->getId() . ')', 'new AssociationBreakAction(AssociationBreakAction::' . $this->action->getId() . ')'); }
protected function getCtorArgumentsPhpCode() { $proxyName = $this->proxy->getLogicalSchema()->getEntityName(); return array($proxyName . '::orm()', $this->container->toPhpCall(), $this->encapsulant->toPhpCall()); }
/** * @aux * @return EntityProperty */ private function guessEntityProperty($path) { $chunks = explode('.', $path); $name = reset($chunks); return $this->processProperty(join('.', array_slice($chunks, 1)), $this->entity->getLogicalSchema()->getProperty($name)); }