123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165 |
- <?php
-
-
- namespace Doctrine\DBAL\Schema;
-
- use Doctrine\DBAL\Schema\Visitor\Visitor;
-
- class ForeignKeyConstraint extends AbstractAsset implements Constraint
- {
-
-
- protected $_localTable;
-
-
-
- protected $_localColumnNames;
-
-
-
- protected $_foreignTableName;
-
-
-
- protected $_foreignColumnNames;
-
-
-
- protected $_cascade = '';
-
-
-
- protected $_options;
-
-
-
- public function __construct(array $localColumnNames, $foreignTableName, array $foreignColumnNames, $name=null, array $options=array())
- {
- $this->_setName($name);
- $this->_localColumnNames = $localColumnNames;
- $this->_foreignTableName = $foreignTableName;
- $this->_foreignColumnNames = $foreignColumnNames;
- $this->_options = $options;
- }
-
-
-
- public function getLocalTableName()
- {
- return $this->_localTable->getName();
- }
-
-
-
- public function setLocalTable(Table $table)
- {
- $this->_localTable = $table;
- }
-
-
-
- public function getLocalColumns()
- {
- return $this->_localColumnNames;
- }
-
- public function getColumns()
- {
- return $this->_localColumnNames;
- }
-
-
-
- public function getForeignTableName()
- {
- return $this->_foreignTableName;
- }
-
-
-
- public function getForeignColumns()
- {
- return $this->_foreignColumnNames;
- }
-
- public function hasOption($name)
- {
- return isset($this->_options[$name]);
- }
-
- public function getOption($name)
- {
- return $this->_options[$name];
- }
-
-
-
- public function onUpdate()
- {
- return $this->_onEvent('onUpdate');
- }
-
-
-
- public function onDelete()
- {
- return $this->_onEvent('onDelete');
- }
-
-
-
- private function _onEvent($event)
- {
- if (isset($this->_options[$event])) {
- $onEvent = strtoupper($this->_options[$event]);
- if (!in_array($onEvent, array('NO ACTION', 'RESTRICT'))) {
- return $onEvent;
- }
- }
- return false;
- }
- }
|