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; }
/** * {@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; }
private function MakeForeignKey(Relational\ITable $Table, Map $ReferencedColumnMap) { return new ForeignKey($this->GetName() . '_' . $Table->GetName(), $ReferencedColumnMap, ForeignKeyMode::Cascade, ForeignKeyMode::Cascade); }
/** * 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()); } }