This can be though of as a SELECT
Author: Elliot Levin (elliot@aanet.com.au)
 public function AddParentPredicateToRequest(Relational\Request $Request, array $ParentRows)
 {
     if (count($ParentRows) > 1) {
         $Request->AddColumns($this->ParentForeignKey->GetParentColumns());
     }
     parent::AddParentPredicateToRequest($Request, $ParentRows);
 }
Exemple #2
0
 public final function AddRelationToRequest(Relational\Request $Request, array $ParentRows = null)
 {
     $Request->AddTable($this->Table);
     $this->AddConstraintToRequest($Request);
     if ($ParentRows !== null && count($ParentRows) > 0) {
         $this->AddParentPredicateToRequest($Request, $ParentRows);
     }
 }
 protected function SelectQuery(QueryBuilder $QueryBuilder, Relational\Request $Request)
 {
     $QueryBuilder->Append('SELECT ');
     foreach ($QueryBuilder->Delimit($Request->GetColumns(), ',') as $Column) {
         $QueryBuilder->AppendExpression(Expression::ReviveColumn($Column));
         $QueryBuilder->AppendIdentifier(' AS #', [$Column->GetIdentifier()]);
     }
     $QueryBuilder->AppendIdentifiers(' FROM # ', array_keys($Request->GetTables()), ', ');
     $this->AppendCriterion($QueryBuilder, $Request->GetCriterion());
 }
Exemple #4
0
 public function AddParentPredicateToRequest(Relational\Request $Request, array $ParentRows)
 {
     $ParentTable = $this->GetParentTable();
     if ($ParentTable) {
         $Request->AddTable($ParentTable);
     }
     $Request->AddColumns($this->GetReferencedColumns());
     $MatchExpressions = [];
     foreach ($ParentRows as $ParentRow) {
         $ReferencedKey = $this->MapParentRowToRelatedKey($this->ForeignKey, $ParentRow);
         $MatchExpressions[] = new Expressions\MatchesColumnDataExpression($ReferencedKey);
     }
     $Request->GetCriterion()->AddPredicateExpression(Expressions\Expression::CompoundBoolean($MatchExpressions, Expressions\Operators\Binary::LogicalOr));
 }
 /**
  * @access private
  * 
  * Maps the supplied properties such that they will be loaded in the given relational request.
  * 
  * @param \Storm\Core\Mapping\IEntityRelationalMap $EntityRelationalMap The relational map of the entity
  * @param \Storm\Core\Relational\Request $RelationalRequest The request to add to
  * @param array|null $Properties The array of properties to map or null if all properties should be mapped
  * @return void
  */
 private function MapPropetiesToRelationalRequest(IEntityRelationalMap $EntityRelationalMap, Relational\Request $RelationalRequest, array $Properties = null)
 {
     if ($Properties === null) {
         $Properties = $EntityRelationalMap->GetMappedProperties();
     }
     $DataPropertyColumnMappings = $EntityRelationalMap->GetDataPropertyColumnMappings();
     $EntityPropertyToOneRelationMappings = $EntityRelationalMap->GetEntityPropertyToOneRelationMappings();
     $CollectionPropertyToManyRelationMappings = $EntityRelationalMap->GetCollectionPropertyToManyRelationMappings();
     foreach ($Properties as $PropertyIdentifier => $Property) {
         if (isset($DataPropertyColumnMappings[$PropertyIdentifier])) {
             $RelationalRequest->AddColumns($DataPropertyColumnMappings[$PropertyIdentifier]->GetReviveColumns());
         } else {
             if (isset($EntityPropertyToOneRelationMappings[$PropertyIdentifier])) {
                 $EntityPropertyToOneRelationMappings[$PropertyIdentifier]->AddToRelationalRequest($this, $RelationalRequest);
             } else {
                 if (isset($CollectionPropertyToManyRelationMappings[$PropertyIdentifier])) {
                     $CollectionPropertyToManyRelationMappings[$PropertyIdentifier]->AddToRelationalRequest($this, $RelationalRequest);
                 }
             }
         }
     }
 }
 public final function AddToRelationalRequest(DomainDatabaseMap $DomainDatabaseMap, Relational\Request $RelationalRequest)
 {
     $RelationalRequest->AddColumns($this->Relation->GetRelationalParentColumns());
 }
Exemple #7
0
 /**
  * Load the rows specified by the request.
  * 
  * @param Request $Request The request to load
  * @return ResultRow[] The loaded result rows
  */
 public final function Load(Request $Request)
 {
     $Columns = [];
     foreach ($Request->GetTables() as $Table) {
         $this->VerifyTable(__METHOD__, $Table);
         $Columns += $Table->GetColumnsByIdentifier();
     }
     $ResultRowData = $this->LoadResultRowData($Request);
     $ResultRow = new ResultRow($Columns, []);
     return array_map([$ResultRow, 'Another'], $ResultRowData);
 }