Discard() публичный Метод

Discard a row from its primary key within the transaction.
public Discard ( PrimaryKey $PrimaryKey ) : void
$PrimaryKey PrimaryKey The primary key to discard
Результат void
Пример #1
0
 public function Persist(Relational\Transaction $Transaction, Relational\ResultRow $ParentData, array $RelationshipChanges)
 {
     $IdentifyingChildRows = [];
     $Table = $this->GetTable();
     $ForeignKey = $this->GetForeignKey();
     foreach ($RelationshipChanges as $RelationshipChange) {
         if ($RelationshipChange->HasPersistedRelationship()) {
             $PersistedRelationship = $RelationshipChange->GetPersistedRelationship();
             if ($PersistedRelationship->IsIdentifying()) {
                 $IdentifyingChildRows[] = $PersistedRelationship->GetChildResultRow();
             }
         }
         if ($RelationshipChange->HasDiscardedRelationship()) {
             $DiscardedRelationship = $RelationshipChange->GetDiscardedRelationship();
             if ($DiscardedRelationship->IsIdentifying()) {
                 $PrimaryKeyToDiscard = $DiscardedRelationship->GetRelatedPrimaryKey();
                 if ($this->IsInversed()) {
                     $ForeignKey->MapReferencedToParentKey($ParentData, $PrimaryKeyToDiscard);
                 } else {
                     $ForeignKey->MapReferencedToParentKey($ParentData, $PrimaryKeyToDiscard);
                 }
                 $Transaction->Discard($PrimaryKeyToDiscard);
             }
         }
     }
     if (count($IdentifyingChildRows) > 0) {
         $this->PersistIdentifyingRelationship($Transaction, $ParentData, $IdentifyingChildRows);
     }
 }
Пример #2
0
 public function Persist(Relational\Transaction $Transaction, Relational\ResultRow $ParentData, array $RelationshipChanges)
 {
     /* @var $RelationshipChanges Relational\RelationshipChange[] */
     $JoinRowsWithoutPrimaryKeys = [];
     foreach ($RelationshipChanges as $RelationshipChange) {
         if ($RelationshipChange->HasPersistedRelationship()) {
             $JoinRow = $this->MapPersistedRelationshipToJoinRow($RelationshipChange->GetPersistedRelationship());
             $Transaction->Persist($JoinRow);
             if (!$JoinRow->HasPrimaryKey()) {
                 $JoinRowsWithoutPrimaryKeys[] = $JoinRow;
             }
         }
         if ($RelationshipChange->HasDiscardedRelationship()) {
             $JoinRow = $this->MapDiscardedRelationshipToJoinRow($RelationshipChange->GetDiscardedRelationship());
             $Transaction->Discard($JoinRow->GetPrimaryKey());
         }
     }
     if (count($JoinRowsWithoutPrimaryKeys) > 0) {
         $ParentRow = $ParentData->GetRow($this->ParentForeignKey->GetReferencedTable());
         $Transaction->SubscribeToPrePersistEvent($this->JoinTable, function () use(&$ParentRow, &$JoinRowsWithoutPrimaryKeys) {
             foreach ($JoinRowsWithoutPrimaryKeys as $JoinRowWithoutPrimaryKey) {
                 $this->ParentForeignKey->MapReferencedToParentKey($ParentRow, $JoinRowWithoutPrimaryKey);
             }
         });
     }
 }