public function __construct(Object\IDataProperty $DataProperty, Relational\IColumn $Column) { parent::__construct($DataProperty); if ($DataProperty->IsIdentity() && !$Column->IsPrimaryKey()) { throw new MappingException('Cannot map an identity property to a non primary key column %s.%s', $Column->GetTable()->GetName(), $Column->GetName()); } else { if ($Column->IsPrimaryKey() && !$DataProperty->IsIdentity()) { throw new MappingException('Cannot map an non identity property to a primary key column %s.%s', $Column->GetTable()->GetName(), $Column->GetName()); } else { if ($Column->IsPrimaryKey() && $DataProperty->IsIdentity()) { $this->IsIdentityPrimaryKeyMapping = true; } } } $this->DataProperty = $DataProperty; $this->Column = $Column; }
public function __construct(IColumn $Column, $Alias = null) { $this->Table = $Column->GetTable(); $this->Column = $Column; $this->Alias = $Alias; }
private function MakeColumnName(Relational\Table $Table, Relational\IColumn $Column) { return $Table->GetName() . '_' . $Column->GetName(); }
/** * Add a column to the table. * * @param IColumn $Column The column to add * @throws InvalidColumnException If the column belongs to another table */ private function AddColumn(IColumn $Column) { if ($Column->HasTable()) { if (!$Column->GetTable()->Is($this)) { throw new InvalidColumnException('The registered column %s is already registered with another table %s.', $Column->GetName(), $Column->GetTable()->GetName()); } } $Column->SetTable($this); $ColumnName = $Column->GetName(); $ColumnIdentifier = $Column->GetIdentifier(); $this->Columns[$ColumnName] = $Column; $this->ColumnsByIdentifiers[$ColumnIdentifier] = $Column; if ($Column->IsPrimaryKey()) { $this->PrimaryKeyColumns[$ColumnName] = $Column; $this->PrimaryKeyColumnByIdentifiers[$ColumnIdentifier] = $Column; } }