2009-11-27 00:56:08 +03:00
|
|
|
<?php
|
2009-11-28 01:00:43 +03:00
|
|
|
/*
|
|
|
|
* $Id$
|
|
|
|
*
|
|
|
|
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
|
|
|
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
|
|
|
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
|
|
|
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
|
|
|
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
|
|
|
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
|
|
|
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
|
|
|
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
|
|
|
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
|
|
|
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
|
|
|
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
|
|
*
|
|
|
|
* This software consists of voluntary contributions made by many individuals
|
|
|
|
* and is licensed under the LGPL. For more information, see
|
|
|
|
* <http://www.doctrine-project.org>.
|
|
|
|
*/
|
2009-11-27 00:56:08 +03:00
|
|
|
|
|
|
|
namespace Doctrine\DBAL\Schema;
|
|
|
|
|
2009-11-28 01:00:43 +03:00
|
|
|
use Doctrine\DBAL\Schema\Visitor\Visitor;
|
|
|
|
|
2009-11-27 00:56:08 +03:00
|
|
|
class ForeignKeyConstraint extends AbstractAsset implements Constraint
|
|
|
|
{
|
2009-12-06 21:36:46 +03:00
|
|
|
/**
|
|
|
|
* @var Table
|
|
|
|
*/
|
|
|
|
protected $_localTable;
|
|
|
|
|
2009-11-27 00:56:08 +03:00
|
|
|
/**
|
|
|
|
* @var array
|
|
|
|
*/
|
|
|
|
protected $_localColumnNames;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @var string
|
|
|
|
*/
|
|
|
|
protected $_foreignTableName;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @var array
|
|
|
|
*/
|
|
|
|
protected $_foreignColumnNames;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @var string
|
|
|
|
*/
|
|
|
|
protected $_cascade = '';
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @var array
|
|
|
|
*/
|
|
|
|
protected $_options;
|
|
|
|
|
|
|
|
/**
|
|
|
|
*
|
|
|
|
* @param array $localColumnNames
|
|
|
|
* @param string $foreignTableName
|
|
|
|
* @param array $foreignColumnNames
|
|
|
|
* @param string $cascade
|
|
|
|
* @param string|null $name
|
|
|
|
*/
|
|
|
|
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;
|
|
|
|
}
|
|
|
|
|
2009-12-06 21:36:46 +03:00
|
|
|
/**
|
|
|
|
* @return string
|
|
|
|
*/
|
|
|
|
public function getLocalTableName()
|
|
|
|
{
|
|
|
|
return $this->_localTable->getName();
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @param Table $table
|
|
|
|
*/
|
|
|
|
public function setLocalTable(Table $table)
|
|
|
|
{
|
|
|
|
$this->_localTable = $table;
|
|
|
|
}
|
|
|
|
|
2009-11-27 00:56:08 +03:00
|
|
|
/**
|
|
|
|
* @return array
|
|
|
|
*/
|
2009-11-30 22:02:05 +03:00
|
|
|
public function getLocalColumns()
|
2009-11-27 00:56:08 +03:00
|
|
|
{
|
2009-12-05 01:41:09 +03:00
|
|
|
return $this->_localColumnNames;
|
2009-11-27 00:56:08 +03:00
|
|
|
}
|
|
|
|
|
2009-12-03 01:28:38 +03:00
|
|
|
public function getColumns()
|
|
|
|
{
|
2009-12-05 01:41:09 +03:00
|
|
|
return $this->_localColumnNames;
|
2009-12-03 01:28:38 +03:00
|
|
|
}
|
|
|
|
|
2009-11-27 00:56:08 +03:00
|
|
|
/**
|
|
|
|
* @return string
|
|
|
|
*/
|
|
|
|
public function getForeignTableName()
|
|
|
|
{
|
2009-12-05 01:41:09 +03:00
|
|
|
return $this->_foreignTableName;
|
2009-11-27 00:56:08 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @return array
|
|
|
|
*/
|
2009-11-30 22:02:05 +03:00
|
|
|
public function getForeignColumns()
|
2009-11-27 00:56:08 +03:00
|
|
|
{
|
2009-12-05 01:41:09 +03:00
|
|
|
return $this->_foreignColumnNames;
|
2009-11-27 00:56:08 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
public function hasOption($name)
|
|
|
|
{
|
|
|
|
return isset($this->_options[$name]);
|
|
|
|
}
|
|
|
|
|
|
|
|
public function getOption($name)
|
|
|
|
{
|
|
|
|
return $this->_options[$name];
|
|
|
|
}
|
|
|
|
}
|