Author: Elliot Levin (elliot@aanet.com.au)
Ejemplo n.º 1
0
 public function SetTable(Relational\ITable $Table)
 {
     if ($this->Table === $Table) {
         return;
     }
     $PrimaryKeyColumns = $Table->GetPrimaryKeyColumns();
     if (count($PrimaryKeyColumns) === 0) {
         throw new Relational\RelationalException('Cannot generate keys for table %s without any primary key columns', $Table->GetName());
     }
     $this->OnSetPrimaryKeyColumns($PrimaryKeyColumns);
     $this->PrimaryKeyColumns = $PrimaryKeyColumns;
 }
Ejemplo n.º 2
0
 /**
  * {@inheritDoc}
  */
 public final function MapIdentitiesToPrimaryKeys(array $Identities)
 {
     $PrimaryKeys = array_map(function () {
         return $this->PrimaryKeyTable->PrimaryKey();
     }, $Identities);
     foreach ($this->IdentityPropertyPrimaryKeyMappings as $Mapping) {
         $Mapping->Persist($Identities, $PrimaryKeys);
     }
     return $PrimaryKeys;
 }
Ejemplo n.º 3
0
 private function MakeForeignKey(Relational\ITable $Table, Map $ReferencedColumnMap)
 {
     return new ForeignKey($this->GetName() . '_' . $Table->GetName(), $ReferencedColumnMap, ForeignKeyMode::Cascade, ForeignKeyMode::Cascade);
 }
Ejemplo n.º 4
0
 /**
  * Verifies a table is registered in this database.
  * 
  * @param ITable $Table The table to verify
  * @throws \InvalidArgumentException If the table is not registered
  */
 private function VerifyTable($Method, ITable $Table)
 {
     if (!$this->HasTable($Table->GetName())) {
         throw new InvalidTableException('Call to %s with supplied table %s does not belong to this database', $Method, $Table->GetName());
     }
 }