/** * @param \obo\Interfaces\IQuerySpecification $specification * @return int */ public function countEntities(\obo\Interfaces\IQuerySpecification $specification = null) { $ownedEntityClassName = $this->entitiesClassName; $ownedEntityManagerName = $ownedEntityClassName::entityInformation()->managerName; return $ownedEntityManagerName::countRecords(\obo\Carriers\QueryCarrier::instance()->addSpecification($this->getSpecification()->addSpecification($specification))); }
/** * @param \obo\Carriers\QueryCarrier $specification * @param string $repositoryName * @param \obo\Entity $owner * @param string $targetEntity */ protected function constructJoinQueryForRelationship(\obo\Carriers\QueryCarrier $specification, $repositoryName, \obo\Entity $owner, $targetEntity) { $targetEntityPropertyNameForSoftDelete = $targetEntity::entityInformation()->propertyNameForSoftDelete; if ($targetEntityPropertyNameForSoftDelete === "") { $specification->join("JOIN [{$repositoryName}] ON [{$owner->entityInformation()->repositoryName}] = " . $this->informationForEntity($owner->entityInformation())["columns"][$owner->entityInformation()->informationForPropertyWithName($owner->entityInformation()->primaryPropertyName)->columnName]["placeholder"] . " AND [{$targetEntity::entityInformation()->repositoryName}] = [{$targetEntity::informationForPropertyWithName($targetEntity::entityInformation()->primaryPropertyName)->columnName}]", $owner->primaryPropertyValue()); } else { $softDeleteJoinQuery = "AND [{$targetEntity::entityInformation()->repositoryName}].[{$targetEntity::informationForPropertyWithName($targetEntityPropertyNameForSoftDelete)->columnName}] = %b"; $specification->join("JOIN [{$repositoryName}] ON [{$owner->entityInformation()->repositoryName}] = " . $this->informationForEntity($owner->entityInformation())["columns"][$owner->entityInformation()->informationForPropertyWithName($owner->entityInformation()->primaryPropertyName)->columnName]["placeholder"] . " AND [{$targetEntity::entityInformation()->repositoryName}] = [{$targetEntity::informationForPropertyWithName($targetEntity::entityInformation()->primaryPropertyName)->columnName}]" . $softDeleteJoinQuery, $owner->primaryPropertyValue(), FALSE); } }
/** * @param \obo\Carriers\QueryCarrier $specification * @return \obo\Entity[] */ protected static function entitiesFromDataStorage(\obo\Carriers\QueryCarrier $specification) { $classNameEntity = self::classNameManagedEntity(); if (($propertyNameForSoftDelete = $classNameEntity::entityInformation()->propertyNameForSoftDelete) !== "") { $specification->where("AND {{$propertyNameForSoftDelete}} = " . \obo\Interfaces\IQuerySpecification::PARAMETER_PLACEHOLDER, FALSE); } $entities = new \obo\Carriers\DataCarrier(); foreach (self::rawDataForSpecification($specification) as $data) { $entity = self::entityFromRawData($data); $entities->setValueForVariableWithName($entity, $entity->primaryPropertyValue()); } return $entities; }