Commit 8a393ab4 authored by zYne's avatar zYne

--no commit message

--no commit message
parent fbe13344
...@@ -229,7 +229,17 @@ class Doctrine_Export extends Doctrine_Connection_Module ...@@ -229,7 +229,17 @@ class Doctrine_Export extends Doctrine_Connection_Module
} }
$name = $this->conn->quoteIdentifier($name, true); $name = $this->conn->quoteIdentifier($name, true);
$query = 'CREATE TABLE ' . $name . ' (' . $queryFields . ')'; $query = 'CREATE TABLE ' . $name . ' (' . $queryFields;
$check = $this->getCheckDeclaration($fields);
if ( ! empty($check)) {
$query .= ', ' . $check;
}
$query .= ')';
$sql[] = $query; $sql[] = $query;
...@@ -694,24 +704,22 @@ class Doctrine_Export extends Doctrine_Connection_Module ...@@ -694,24 +704,22 @@ class Doctrine_Export extends Doctrine_Connection_Module
*/ */
public function getCheckDeclaration(array $definition) public function getCheckDeclaration(array $definition)
{ {
$query .= 'CHECK ';
$constraints = array(); $constraints = array();
foreach ($definition as $field => $def) { foreach ($definition as $field => $def) {
if (is_string($def)) {
$constraints[] = 'CHECK (' . $def . ')';
} else {
if (isset($def['min'])) { if (isset($def['min'])) {
$constraints[] = 'CHECK (' . $field . ' > ' . $def['min'] . ')'; $constraints[] = 'CHECK (' . $field . ' >= ' . $def['min'] . ')';
} }
if (isset($def['max'])) { if (isset($def['max'])) {
$constraints[] = 'CHECK (' . $field . ' < ' . $def['max'] . ')'; $constraints[] = 'CHECK (' . $field . ' <= ' . $def['max'] . ')';
} }
if (is_string($def)) {
$constraints[] = 'CHECK (' . $def . ')';
} }
} }
$query .= implode(', ', $constraints); return implode(', ', $constraints);
} }
/** /**
* Obtain DBMS specific SQL code portion needed to set an index * Obtain DBMS specific SQL code portion needed to set an index
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment