1
0
mirror of synced 2025-01-18 06:21:40 +03:00
This commit is contained in:
zYne 2007-07-23 23:18:11 +00:00
parent 23025b5872
commit cfaa5f121f
2 changed files with 33 additions and 2 deletions

View File

@ -180,7 +180,19 @@ class Doctrine_Export_Sqlite extends Doctrine_Export
}
$name = $this->conn->quoteIdentifier($name, true);
$query[] = 'CREATE TABLE ' . $name . ' (' . $queryFields . ')';
$sql = 'CREATE TABLE ' . $name . ' (' . $queryFields . ')';
if ($check = $this->getCheckDeclaration($fields)) {
$sql .= ', ' . $check;
}
if (isset($options['checks']) && $check = $this->getCheckDeclaration($options['checks'])) {
$sql .= ', ' . $check;
}
$sql .= ')';
$query[] = $sql;
if (isset($options['indexes']) && ! empty($options['indexes'])) {
foreach ($options['indexes'] as $index => $definition) {

View File

@ -121,7 +121,9 @@ class Doctrine_Table extends Doctrine_Configurable implements Countable
*
* -- foreignKeys the foreign keys of this table
*
* -- collation
* -- checks the check constraints of this table, eg. 'price > dicounted_price'
*
* -- collation collation attribute
*
* -- indexes the index definitions of this table
*
@ -468,6 +470,23 @@ class Doctrine_Table extends Doctrine_Configurable implements Countable
{
$this->options['foreignKeys'][] = $definition;
}
/**
* addCheckConstraint
*
* adds a check constraint to this table
*
* @return void
*/
public function addCheckConstraint($definition, $name)
{
if (is_string($name)) {
$this->options['checks'][$name] = $definition;
} else {
$this->options['checks'][] = $definition;
}
return $this;
}
/**
* addIndex
*