Commit 239995d3 authored by lsmith's avatar lsmith

- fixed switch statement formating according to ZF CS

parent b4ac430d
...@@ -308,37 +308,37 @@ class Doctrine_Collection extends Doctrine_Access implements Countable, Iterator ...@@ -308,37 +308,37 @@ class Doctrine_Collection extends Doctrine_Access implements Countable, Iterator
$offset = null; $offset = null;
switch (get_class($this)) { switch (get_class($this)) {
case "Doctrine_Collection_Offset": case "Doctrine_Collection_Offset":
$limit = $this->getLimit(); $limit = $this->getLimit();
$offset = (floor($key / $limit) * $limit); $offset = (floor($key / $limit) * $limit);
if ( ! $this->expandable && isset($this->expanded[$offset])) { if ( ! $this->expandable && isset($this->expanded[$offset])) {
return false; return false;
} }
$fields = implode(", ",$this->table->getColumnNames());
break;
default:
if ( ! $this->expandable) {
return false;
}
if ( ! isset($this->reference)) {
return false;
}
$id = $this->reference->obtainIdentifier();
if (empty($id)) {
return false;
}
switch (get_class($this)) {
case "Doctrine_Collection_Immediate":
$fields = implode(", ",$this->table->getColumnNames()); $fields = implode(", ",$this->table->getColumnNames());
break; break;
default: default:
$fields = implode(", ",$this->table->getPrimaryKeys()); if ( ! $this->expandable) {
}; return false;
}
if ( ! isset($this->reference)) {
return false;
}
$id = $this->reference->obtainIdentifier();
if (empty($id)) {
return false;
}
switch (get_class($this)) {
case "Doctrine_Collection_Immediate":
$fields = implode(", ",$this->table->getColumnNames());
break;
default:
$fields = implode(", ",$this->table->getPrimaryKeys());
};
}; };
if (isset($this->relation)) { if (isset($this->relation)) {
......
...@@ -155,13 +155,13 @@ class Doctrine_Collection_Batch extends Doctrine_Collection ...@@ -155,13 +155,13 @@ class Doctrine_Collection_Batch extends Doctrine_Collection
{ {
if (isset($this->data[$key])) { if (isset($this->data[$key])) {
switch (gettype($this->data[$key])) { switch (gettype($this->data[$key])) {
case "array": case "array":
// Doctrine_Record didn't exist in cache // Doctrine_Record didn't exist in cache
$this->table->setData($this->data[$key]); $this->table->setData($this->data[$key]);
$this->data[$key] = $this->table->getProxy(); $this->data[$key] = $this->table->getProxy();
$this->data[$key]->addCollection($this); $this->data[$key]->addCollection($this);
break; break;
}; };
} else { } else {
$this->expand($key); $this->expand($key);
......
...@@ -64,88 +64,88 @@ abstract class Doctrine_Configurable ...@@ -64,88 +64,88 @@ abstract class Doctrine_Configurable
public function setAttribute($attribute,$value) public function setAttribute($attribute,$value)
{ {
switch ($attribute) { switch ($attribute) {
case Doctrine::ATTR_BATCH_SIZE: case Doctrine::ATTR_BATCH_SIZE:
if ($value < 0) { if ($value < 0) {
throw new Doctrine_Exception("Batch size should be greater than or equal to zero"); throw new Doctrine_Exception("Batch size should be greater than or equal to zero");
}
break;
case Doctrine::ATTR_FETCHMODE:
if ($value < 0) {
throw new Doctrine_Exception("Unknown fetchmode. See Doctrine::FETCH_* constants.");
}
break;
case Doctrine::ATTR_LISTENER:
$this->setEventListener($value);
break;
case Doctrine::ATTR_LOCKMODE:
if ($this instanceof Doctrine_Connection) {
if ($this->transaction->getState() != Doctrine_Transaction::STATE_SLEEP) {
throw new Doctrine_Exception("Couldn't set lockmode. There are transactions open.");
} }
} elseif ($this instanceof Doctrine_Manager) { break;
foreach ($this as $connection) {
if ($connection->transaction->getState() != Doctrine_Transaction::STATE_SLEEP) { case Doctrine::ATTR_FETCHMODE:
if ($value < 0) {
throw new Doctrine_Exception("Unknown fetchmode. See Doctrine::FETCH_* constants.");
}
break;
case Doctrine::ATTR_LISTENER:
$this->setEventListener($value);
break;
case Doctrine::ATTR_LOCKMODE:
if ($this instanceof Doctrine_Connection) {
if ($this->transaction->getState() != Doctrine_Transaction::STATE_SLEEP) {
throw new Doctrine_Exception("Couldn't set lockmode. There are transactions open."); throw new Doctrine_Exception("Couldn't set lockmode. There are transactions open.");
} }
} elseif ($this instanceof Doctrine_Manager) {
foreach ($this as $connection) {
if ($connection->transaction->getState() != Doctrine_Transaction::STATE_SLEEP) {
throw new Doctrine_Exception("Couldn't set lockmode. There are transactions open.");
}
}
} else {
throw new Doctrine_Exception("Lockmode attribute can only be set at the global or connection level.");
} }
} else { break;
throw new Doctrine_Exception("Lockmode attribute can only be set at the global or connection level."); case Doctrine::ATTR_CREATE_TABLES:
} $value = (bool) $value;
break; break;
case Doctrine::ATTR_CREATE_TABLES: case Doctrine::ATTR_ACCESSORS:
$value = (bool) $value; $accessors = array('none','get','set','both');
break;
case Doctrine::ATTR_ACCESSORS: // if ( ! in_array($value,$accessors)) {
$accessors = array('none','get','set','both'); // throw new Doctrine_Exception();
// }
// if ( ! in_array($value,$accessors)) {
// throw new Doctrine_Exception(); break;
// } case Doctrine::ATTR_COLL_LIMIT:
if ($value < 1) {
break; throw new Doctrine_Exception("Collection limit should be a value greater than or equal to 1.");
case Doctrine::ATTR_COLL_LIMIT: }
if ($value < 1) { break;
throw new Doctrine_Exception("Collection limit should be a value greater than or equal to 1."); case Doctrine::ATTR_COLL_KEY:
} if ( ! ($this instanceof Doctrine_Table)) {
break; throw new Doctrine_Exception("This attribute can only be set at table level.");
case Doctrine::ATTR_COLL_KEY: }
if ( ! ($this instanceof Doctrine_Table)) { if ( ! $this->hasColumn($value)) {
throw new Doctrine_Exception("This attribute can only be set at table level."); throw new Doctrine_Exception("Couldn't set collection key attribute. No such column '$value'");
} }
if ( ! $this->hasColumn($value)) { break;
throw new Doctrine_Exception("Couldn't set collection key attribute. No such column '$value'"); case Doctrine::ATTR_VLD:
} case Doctrine::ATTR_AUTO_LENGTH_VLD:
break; case Doctrine::ATTR_AUTO_TYPE_VLD:
case Doctrine::ATTR_VLD: case Doctrine::ATTR_QUERY_LIMIT:
case Doctrine::ATTR_AUTO_LENGTH_VLD: case Doctrine::ATTR_QUOTE_IDENTIFIER:
case Doctrine::ATTR_AUTO_TYPE_VLD: case Doctrine::ATTR_PORTABILITY:
case Doctrine::ATTR_QUERY_LIMIT: case Doctrine::ATTR_DEFAULT_TABLE_TYPE:
case Doctrine::ATTR_QUOTE_IDENTIFIER: case Doctrine::ATTR_ACCESSOR_PREFIX_GET:
case Doctrine::ATTR_PORTABILITY: case Doctrine::ATTR_ACCESSOR_PREFIX_SET:
case Doctrine::ATTR_DEFAULT_TABLE_TYPE:
case Doctrine::ATTR_ACCESSOR_PREFIX_GET: break;
case Doctrine::ATTR_ACCESSOR_PREFIX_SET: case Doctrine::ATTR_SEQCOL_NAME:
if ( ! is_string($value)) {
break; throw new Doctrine_Exception('Sequence column name attribute only accepts string values');
case Doctrine::ATTR_SEQCOL_NAME: }
if ( ! is_string($value)) { break;
throw new Doctrine_Exception('Sequence column name attribute only accepts string values'); case Doctrine::ATTR_FIELD_CASE:
} if ($value != 0 && $value != CASE_LOWER && $value != CASE_UPPER)
break; throw new Doctrine_Exception('Field case attribute should be either 0, CASE_LOWER or CASE_UPPER constant.');
case Doctrine::ATTR_FIELD_CASE: break;
if ($value != 0 && $value != CASE_LOWER && $value != CASE_UPPER) case Doctrine::ATTR_SEQNAME_FORMAT:
throw new Doctrine_Exception('Field case attribute should be either 0, CASE_LOWER or CASE_UPPER constant.'); case Doctrine::ATTR_IDXNAME_FORMAT:
break; if ($this instanceof Doctrine_Table) {
case Doctrine::ATTR_SEQNAME_FORMAT: throw new Doctrine_Exception('Sequence / index name format attributes cannot be set'
case Doctrine::ATTR_IDXNAME_FORMAT: . 'at table level (only at connection or global level).');
if ($this instanceof Doctrine_Table) { }
throw new Doctrine_Exception('Sequence / index name format attributes cannot be set' break;
. 'at table level (only at connection or global level).'); default:
} throw new Doctrine_Exception("Unknown attribute.");
break;
default:
throw new Doctrine_Exception("Unknown attribute.");
}; };
$this->attributes[$attribute] = $value; $this->attributes[$attribute] = $value;
......
...@@ -160,13 +160,13 @@ abstract class Doctrine_Connection extends Doctrine_Configurable implements Coun ...@@ -160,13 +160,13 @@ abstract class Doctrine_Connection extends Doctrine_Configurable implements Coun
} }
if ($this->modules[$name] === false) { if ($this->modules[$name] === false) {
switch ($name) { switch ($name) {
case 'unitOfWork': case 'unitOfWork':
$this->modules[$name] = new Doctrine_Connection_UnitOfWork($this); $this->modules[$name] = new Doctrine_Connection_UnitOfWork($this);
break; break;
default: default:
$class = 'Doctrine_' . ucwords($name) . '_' . $this->getName(); $class = 'Doctrine_' . ucwords($name) . '_' . $this->getName();
$this->modules[$name] = new $class($this); $this->modules[$name] = new $class($this);
} }
} }
return $this->modules[$name]; return $this->modules[$name];
...@@ -291,21 +291,21 @@ abstract class Doctrine_Connection extends Doctrine_Configurable implements Coun ...@@ -291,21 +291,21 @@ abstract class Doctrine_Connection extends Doctrine_Configurable implements Coun
$type = gettype($input); $type = gettype($input);
} }
switch ($type) { switch ($type) {
case 'integer': case 'integer':
case 'enum': case 'enum':
case 'boolean': case 'boolean':
return $input; return $input;
case 'array': case 'array':
case 'object': case 'object':
$input = serialize($input); $input = serialize($input);
case 'string': case 'string':
case 'char': case 'char':
case 'varchar': case 'varchar':
case 'text': case 'text':
case 'gzip': case 'gzip':
case 'blob': case 'blob':
case 'clob': case 'clob':
return $this->dbh->quote($input); return $this->dbh->quote($input);
} }
} }
/** /**
...@@ -874,17 +874,17 @@ abstract class Doctrine_Connection extends Doctrine_Configurable implements Coun ...@@ -874,17 +874,17 @@ abstract class Doctrine_Connection extends Doctrine_Configurable implements Coun
$record->getTable()->getAttribute(Doctrine::ATTR_LISTENER)->onPreSave($record); $record->getTable()->getAttribute(Doctrine::ATTR_LISTENER)->onPreSave($record);
switch ($record->getState()) { switch ($record->getState()) {
case Doctrine_Record::STATE_TDIRTY: case Doctrine_Record::STATE_TDIRTY:
$this->unitOfWork->insert($record); $this->unitOfWork->insert($record);
break; break;
case Doctrine_Record::STATE_DIRTY: case Doctrine_Record::STATE_DIRTY:
case Doctrine_Record::STATE_PROXY: case Doctrine_Record::STATE_PROXY:
$this->unitOfWork->update($record); $this->unitOfWork->update($record);
break; break;
case Doctrine_Record::STATE_CLEAN: case Doctrine_Record::STATE_CLEAN:
case Doctrine_Record::STATE_TCLEAN: case Doctrine_Record::STATE_TCLEAN:
// do nothing // do nothing
break; break;
}; };
$record->getTable()->getAttribute(Doctrine::ATTR_LISTENER)->onSave($record); $record->getTable()->getAttribute(Doctrine::ATTR_LISTENER)->onSave($record);
......
...@@ -204,11 +204,11 @@ class Doctrine_Connection_UnitOfWork extends Doctrine_Connection_Module implemen ...@@ -204,11 +204,11 @@ class Doctrine_Connection_UnitOfWork extends Doctrine_Connection_Module implemen
{ {
foreach ($record->getTable()->getRelations() as $fk) { foreach ($record->getTable()->getRelations() as $fk) {
switch ($fk->getType()) { switch ($fk->getType()) {
case Doctrine_Relation::ONE_COMPOSITE: case Doctrine_Relation::ONE_COMPOSITE:
case Doctrine_Relation::MANY_COMPOSITE: case Doctrine_Relation::MANY_COMPOSITE:
$obj = $record->get($fk->getAlias()); $obj = $record->get($fk->getAlias());
$obj->delete(); $obj->delete();
break; break;
}; };
} }
} }
...@@ -263,12 +263,12 @@ class Doctrine_Connection_UnitOfWork extends Doctrine_Connection_Module implemen ...@@ -263,12 +263,12 @@ class Doctrine_Connection_UnitOfWork extends Doctrine_Connection_Module implemen
if ($value instanceof Doctrine_Record) { if ($value instanceof Doctrine_Record) {
switch ($value->getState()) { switch ($value->getState()) {
case Doctrine_Record::STATE_TCLEAN: case Doctrine_Record::STATE_TCLEAN:
case Doctrine_Record::STATE_TDIRTY: case Doctrine_Record::STATE_TDIRTY:
$record->save(); $record->save();
default: default:
$array[$name] = $value->getIncremented(); $array[$name] = $value->getIncremented();
$record->set($name, $value->getIncremented()); $record->set($name, $value->getIncremented());
}; };
} }
}; };
......
...@@ -57,38 +57,38 @@ class Doctrine_DataDict_Firebird extends Doctrine_DataDict ...@@ -57,38 +57,38 @@ class Doctrine_DataDict_Firebird extends Doctrine_DataDict
public function getNativeDeclaration($field) public function getNativeDeclaration($field)
{ {
switch ($field['type']) { switch ($field['type']) {
case 'varchar': case 'varchar':
case 'string': case 'string':
case 'array': case 'array':
case 'object': case 'object':
case 'char': case 'char':
case 'text': case 'text':
$length = !empty($field['length']) $length = !empty($field['length'])
? $field['length'] : 16777215; // TODO: $db->options['default_text_field_length']; ? $field['length'] : 16777215; // TODO: $db->options['default_text_field_length'];
$fixed = ((isset($field['fixed']) && $field['fixed']) || $field['type'] == 'char') ? true : false; $fixed = ((isset($field['fixed']) && $field['fixed']) || $field['type'] == 'char') ? true : false;
return $fixed ? 'CHAR('.$length.')' : 'VARCHAR('.$length.')'; return $fixed ? 'CHAR('.$length.')' : 'VARCHAR('.$length.')';
case 'clob': case 'clob':
return 'BLOB SUB_TYPE 1'; return 'BLOB SUB_TYPE 1';
case 'blob': case 'blob':
return 'BLOB SUB_TYPE 0'; return 'BLOB SUB_TYPE 0';
case 'integer': case 'integer':
case 'enum': case 'enum':
return 'INT'; return 'INT';
case 'boolean': case 'boolean':
return 'SMALLINT'; return 'SMALLINT';
case 'date': case 'date':
return 'DATE'; return 'DATE';
case 'time': case 'time':
return 'TIME'; return 'TIME';
case 'timestamp': case 'timestamp':
return 'TIMESTAMP'; return 'TIMESTAMP';
case 'float': case 'float':
return 'DOUBLE PRECISION'; return 'DOUBLE PRECISION';
case 'decimal': case 'decimal':
$length = !empty($field['length']) ? $field['length'] : 18; $length = !empty($field['length']) ? $field['length'] : 18;
return 'DECIMAL('.$length.','.$db->options['decimal_places'].')'; return 'DECIMAL('.$length.','.$db->options['decimal_places'].')';
} }
return ''; return '';
} }
...@@ -129,7 +129,7 @@ class Doctrine_DataDict_Firebird extends Doctrine_DataDict ...@@ -129,7 +129,7 @@ class Doctrine_DataDict_Firebird extends Doctrine_DataDict
$type = array_reverse($type); $type = array_reverse($type);
} }
} }
break; break;
case 'varchar': case 'varchar':
$fixed = false; $fixed = false;
case 'char': case 'char':
...@@ -144,15 +144,15 @@ class Doctrine_DataDict_Firebird extends Doctrine_DataDict ...@@ -144,15 +144,15 @@ class Doctrine_DataDict_Firebird extends Doctrine_DataDict
if ($fixed !== false) { if ($fixed !== false) {
$fixed = true; $fixed = true;
} }
break; break;
case 'date': case 'date':
$type[] = 'date'; $type[] = 'date';
$length = null; $length = null;
break; break;
case 'timestamp': case 'timestamp':
$type[] = 'timestamp'; $type[] = 'timestamp';
$length = null; $length = null;
break; break;
case 'time': case 'time':
$type[] = 'time'; $type[] = 'time';
$length = null; $length = null;
......
...@@ -57,50 +57,50 @@ class Doctrine_DataDict_Informix extends Doctrine_DataDict ...@@ -57,50 +57,50 @@ class Doctrine_DataDict_Informix extends Doctrine_DataDict
public function getNativeDeclaration($field) public function getNativeDeclaration($field)
{ {
switch ($field['type']) { switch ($field['type']) {
case 'char': case 'char':
case 'varchar': case 'varchar':
case 'array': case 'array':
case 'object': case 'object':
case 'string': case 'string':
if (empty($field['length']) && array_key_exists('default', $field)) { if (empty($field['length']) && array_key_exists('default', $field)) {
$field['length'] = $this->conn->varchar_max_length; $field['length'] = $this->conn->varchar_max_length;
}
$length = (! empty($field['length'])) ? $field['length'] : false;
$fixed = ((isset($field['fixed']) && $field['fixed']) || $field['type'] == 'char') ? true : false;
return $fixed ? ($length ? 'CHAR('.$length.')' : 'CHAR(255)')
: ($length ? 'VARCHAR('.$length.')' : 'NVARCHAR');
case 'clob':
return 'TEXT';
case 'blob':
return 'BLOB';
case 'integer':
if (!empty($field['length'])) {
$length = $field['length'];
if ($length <= 1) {
return 'SMALLINT';
} elseif ($length == 2) {
return 'SMALLINT';
} elseif ($length == 3 || $length == 4) {
return 'INTEGER';
} elseif ($length > 4) {
return 'DECIMAL(20)';
} }
}
return 'INT'; $length = (! empty($field['length'])) ? $field['length'] : false;
case 'boolean': $fixed = ((isset($field['fixed']) && $field['fixed']) || $field['type'] == 'char') ? true : false;
return 'SMALLINT';
case 'date': return $fixed ? ($length ? 'CHAR('.$length.')' : 'CHAR(255)')
return 'DATE'; : ($length ? 'VARCHAR('.$length.')' : 'NVARCHAR');
case 'time': case 'clob':
return 'DATETIME YEAR TO SECOND'; return 'TEXT';
case 'timestamp': case 'blob':
return 'DATETIME'; return 'BLOB';
case 'float': case 'integer':
return 'FLOAT'; if (!empty($field['length'])) {
case 'decimal': $length = $field['length'];
return 'DECIMAL'; if ($length <= 1) {
return 'SMALLINT';
} elseif ($length == 2) {
return 'SMALLINT';
} elseif ($length == 3 || $length == 4) {
return 'INTEGER';
} elseif ($length > 4) {
return 'DECIMAL(20)';
}
}
return 'INT';
case 'boolean':
return 'SMALLINT';
case 'date':
return 'DATE';
case 'time':
return 'DATETIME YEAR TO SECOND';
case 'timestamp':
return 'DATETIME';
case 'float':
return 'FLOAT';
case 'decimal':
return 'DECIMAL';
} }
return ''; return '';
} }
......
...@@ -59,51 +59,51 @@ class Doctrine_DataDict_Mssql extends Doctrine_DataDict ...@@ -59,51 +59,51 @@ class Doctrine_DataDict_Mssql extends Doctrine_DataDict
public function getNativeDeclaration($field) public function getNativeDeclaration($field)
{ {
switch ($field['type']) { switch ($field['type']) {
case 'array': case 'array':
case 'object': case 'object':
case 'text': case 'text':
case 'char': case 'char':
case 'varchar': case 'varchar':
case 'string': case 'string':
$length = !empty($field['length']) $length = !empty($field['length'])
? $field['length'] : false; ? $field['length'] : false;
$fixed = ((isset($field['fixed']) && $field['fixed']) || $field['type'] == 'char') ? true : false; $fixed = ((isset($field['fixed']) && $field['fixed']) || $field['type'] == 'char') ? true : false;
return $fixed ? ($length ? 'CHAR('.$length.')' : 'CHAR('.$db->options['default_text_field_length'].')') return $fixed ? ($length ? 'CHAR('.$length.')' : 'CHAR('.$db->options['default_text_field_length'].')')
: ($length ? 'VARCHAR('.$length.')' : 'TEXT'); : ($length ? 'VARCHAR('.$length.')' : 'TEXT');
case 'clob': case 'clob':
if (!empty($field['length'])) { if (!empty($field['length'])) {
$length = $field['length']; $length = $field['length'];
if ($length <= 8000) { if ($length <= 8000) {
return 'VARCHAR('.$length.')'; return 'VARCHAR('.$length.')';
} }
} }
return 'TEXT'; return 'TEXT';
case 'blob': case 'blob':
if (!empty($field['length'])) { if (!empty($field['length'])) {
$length = $field['length']; $length = $field['length'];
if ($length <= 8000) { if ($length <= 8000) {
return "VARBINARY($length)"; return "VARBINARY($length)";
}
} }
} return 'IMAGE';
return 'IMAGE'; case 'integer':
case 'integer': case 'enum':
case 'enum': return 'INT';
return 'INT'; case 'boolean':
case 'boolean': return 'BIT';
return 'BIT'; case 'date':
case 'date': return 'CHAR(' . strlen('YYYY-MM-DD') . ')';
return 'CHAR(' . strlen('YYYY-MM-DD') . ')'; case 'time':
case 'time': return 'CHAR(' . strlen('HH:MM:SS') . ')';
return 'CHAR(' . strlen('HH:MM:SS') . ')'; case 'timestamp':
case 'timestamp': return 'CHAR(' . strlen('YYYY-MM-DD HH:MM:SS') . ')';
return 'CHAR(' . strlen('YYYY-MM-DD HH:MM:SS') . ')'; case 'float':
case 'float': return 'FLOAT';
return 'FLOAT'; case 'decimal':
case 'decimal': $length = !empty($field['length']) ? $field['length'] : 18;
$length = !empty($field['length']) ? $field['length'] : 18; return 'DECIMAL('.$length.','.$db->options['decimal_places'].')';
return 'DECIMAL('.$length.','.$db->options['decimal_places'].')';
} }
return ''; return '';
} }
...@@ -124,48 +124,48 @@ class Doctrine_DataDict_Mssql extends Doctrine_DataDict ...@@ -124,48 +124,48 @@ class Doctrine_DataDict_Mssql extends Doctrine_DataDict
// todo: unsigned handling seems to be missing // todo: unsigned handling seems to be missing
$unsigned = $fixed = null; $unsigned = $fixed = null;
switch ($db_type) { switch ($db_type) {
case 'bit': case 'bit':
$type[0] = 'boolean'; $type[0] = 'boolean';
break; break;
case 'int': case 'int':
$type[0] = 'integer'; $type[0] = 'integer';
break; break;
case 'datetime': case 'datetime':
$type[0] = 'timestamp'; $type[0] = 'timestamp';
break; break;
case 'float': case 'float':
case 'real': case 'real':
case 'numeric': case 'numeric':
$type[0] = 'float'; $type[0] = 'float';
break; break;
case 'decimal': case 'decimal':
case 'money': case 'money':
$type[0] = 'decimal'; $type[0] = 'decimal';
break; break;
case 'text': case 'text':
case 'varchar': case 'varchar':
$fixed = false; $fixed = false;
case 'char': case 'char':
$type[0] = 'text'; $type[0] = 'text';
if ($length == '1') { if ($length == '1') {
$type[] = 'boolean'; $type[] = 'boolean';
if (preg_match('/^[is|has]/', $field['name'])) { if (preg_match('/^[is|has]/', $field['name'])) {
$type = array_reverse($type); $type = array_reverse($type);
}
} elseif (strstr($db_type, 'text')) {
$type[] = 'clob';
} }
} elseif (strstr($db_type, 'text')) { if ($fixed !== false) {
$type[] = 'clob'; $fixed = true;
} }
if ($fixed !== false) { break;
$fixed = true; case 'image':
} case 'varbinary':
break; $type[] = 'blob';
case 'image': $length = null;
case 'varbinary': break;
$type[] = 'blob'; default:
$length = null; throw new Doctrine_DataDict_Mssql_Exception('unknown database attribute type: '.$db_type);
break;
default:
throw new Doctrine_DataDict_Mssql_Exception('unknown database attribute type: '.$db_type);
} }
return array($type, $length, $unsigned, $fixed); return array($type, $length, $unsigned, $fixed);
......
...@@ -236,122 +236,122 @@ class Doctrine_DataDict_Mysql extends Doctrine_DataDict ...@@ -236,122 +236,122 @@ class Doctrine_DataDict_Mysql extends Doctrine_DataDict
$type = array(); $type = array();
$unsigned = $fixed = null; $unsigned = $fixed = null;
switch ($dbType) { switch ($dbType) {
case 'tinyint': case 'tinyint':
$type[] = 'integer'; $type[] = 'integer';
$type[] = 'boolean';
if (preg_match('/^(is|has)/', $field['name'])) {
$type = array_reverse($type);
}
$unsigned = preg_match('/ unsigned/i', $field['type']);
$length = 1;
break;
case 'smallint':
$type[] = 'integer';
$unsigned = preg_match('/ unsigned/i', $field['type']);
$length = 2;
break;
case 'mediumint':
$type[] = 'integer';
$unsigned = preg_match('/ unsigned/i', $field['type']);
$length = 3;
break;
case 'int':
case 'integer':
$type[] = 'integer';
$unsigned = preg_match('/ unsigned/i', $field['type']);
$length = 4;
break;
case 'bigint':
$type[] = 'integer';
$unsigned = preg_match('/ unsigned/i', $field['type']);
$length = 8;
break;
case 'tinytext':
case 'mediumtext':
case 'longtext':
case 'text':
case 'text':
case 'varchar':
$fixed = false;
case 'string':
case 'char':
$type[] = 'text';
if ($length == '1') {
$type[] = 'boolean'; $type[] = 'boolean';
if (preg_match('/^(is|has)/', $field['name'])) { if (preg_match('/^(is|has)/', $field['name'])) {
$type = array_reverse($type); $type = array_reverse($type);
} }
} elseif (strstr($dbType, 'text')) { $unsigned = preg_match('/ unsigned/i', $field['type']);
$type[] = 'clob'; $length = 1;
if ($decimal == 'binary') { break;
$type[] = 'blob'; case 'smallint':
} $type[] = 'integer';
} $unsigned = preg_match('/ unsigned/i', $field['type']);
if ($fixed !== false) { $length = 2;
$fixed = true; break;
} case 'mediumint':
break; $type[] = 'integer';
case 'enum': $unsigned = preg_match('/ unsigned/i', $field['type']);
$type[] = 'text'; $length = 3;
preg_match_all('/\'.+\'/U', $field['type'], $matches); break;
$length = 0; case 'int':
$fixed = false; case 'integer':
if (is_array($matches)) { $type[] = 'integer';
foreach ($matches[0] as $value) { $unsigned = preg_match('/ unsigned/i', $field['type']);
$length = max($length, strlen($value)-2); $length = 4;
} break;
if ($length == '1' && count($matches[0]) == 2) { case 'bigint':
$type[] = 'integer';
$unsigned = preg_match('/ unsigned/i', $field['type']);
$length = 8;
break;
case 'tinytext':
case 'mediumtext':
case 'longtext':
case 'text':
case 'text':
case 'varchar':
$fixed = false;
case 'string':
case 'char':
$type[] = 'text';
if ($length == '1') {
$type[] = 'boolean'; $type[] = 'boolean';
if (preg_match('/^(is|has)/', $field['name'])) { if (preg_match('/^(is|has)/', $field['name'])) {
$type = array_reverse($type); $type = array_reverse($type);
} }
} elseif (strstr($dbType, 'text')) {
$type[] = 'clob';
if ($decimal == 'binary') {
$type[] = 'blob';
}
} }
} if ($fixed !== false) {
$type[] = 'integer'; $fixed = true;
case 'set': }
$fixed = false; break;
$type[] = 'text'; case 'enum':
$type[] = 'integer'; $type[] = 'text';
break; preg_match_all('/\'.+\'/U', $field['type'], $matches);
case 'date': $length = 0;
$type[] = 'date'; $fixed = false;
$length = null; if (is_array($matches)) {
break; foreach ($matches[0] as $value) {
case 'datetime': $length = max($length, strlen($value)-2);
case 'timestamp': }
$type[] = 'timestamp'; if ($length == '1' && count($matches[0]) == 2) {
$length = null; $type[] = 'boolean';
break; if (preg_match('/^(is|has)/', $field['name'])) {
case 'time': $type = array_reverse($type);
$type[] = 'time'; }
$length = null; }
break; }
case 'float': $type[] = 'integer';
case 'double': case 'set':
case 'real': $fixed = false;
$type[] = 'float'; $type[] = 'text';
$unsigned = preg_match('/ unsigned/i', $field['type']); $type[] = 'integer';
break; break;
case 'unknown': case 'date':
case 'decimal': $type[] = 'date';
case 'numeric': $length = null;
$type[] = 'decimal'; break;
$unsigned = preg_match('/ unsigned/i', $field['type']); case 'datetime':
break; case 'timestamp':
case 'tinyblob': $type[] = 'timestamp';
case 'mediumblob': $length = null;
case 'longblob': break;
case 'blob': case 'time':
$type[] = 'blob'; $type[] = 'time';
$length = null; $length = null;
break; break;
case 'year': case 'float':
$type[] = 'integer'; case 'double':
$type[] = 'date'; case 'real':
$length = null; $type[] = 'float';
break; $unsigned = preg_match('/ unsigned/i', $field['type']);
default: break;
throw new Doctrine_DataDict_Mysql_Exception('unknown database attribute type: '.$dbType); case 'unknown':
case 'decimal':
case 'numeric':
$type[] = 'decimal';
$unsigned = preg_match('/ unsigned/i', $field['type']);
break;
case 'tinyblob':
case 'mediumblob':
case 'longblob':
case 'blob':
$type[] = 'blob';
$length = null;
break;
case 'year':
$type[] = 'integer';
$type[] = 'date';
$length = null;
break;
default:
throw new Doctrine_DataDict_Mysql_Exception('unknown database attribute type: '.$dbType);
} }
return array($type, $length, $unsigned, $fixed); return array($type, $length, $unsigned, $fixed);
......
...@@ -54,38 +54,38 @@ class Doctrine_DataDict_Oracle extends Doctrine_DataDict ...@@ -54,38 +54,38 @@ class Doctrine_DataDict_Oracle extends Doctrine_DataDict
public function getNativeDeclaration(array $field) public function getNativeDeclaration(array $field)
{ {
switch ($field['type']) { switch ($field['type']) {
case 'string': case 'string':
case 'array': case 'array':
case 'object': case 'object':
case 'gzip': case 'gzip':
case 'char': case 'char':
case 'varchar': case 'varchar':
$length = !empty($field['length']) $length = !empty($field['length'])
? $field['length'] : 16777215; // TODO: $db->options['default_text_field_length']; ? $field['length'] : 16777215; // TODO: $db->options['default_text_field_length'];
$fixed = ((isset($field['fixed']) && $field['fixed']) || $field['type'] == 'char') ? true : false; $fixed = ((isset($field['fixed']) && $field['fixed']) || $field['type'] == 'char') ? true : false;
return $fixed ? 'CHAR('.$length.')' : 'VARCHAR2('.$length.')'; return $fixed ? 'CHAR('.$length.')' : 'VARCHAR2('.$length.')';
case 'clob': case 'clob':
return 'CLOB'; return 'CLOB';
case 'blob': case 'blob':
return 'BLOB'; return 'BLOB';
case 'integer': case 'integer':
case 'enum': case 'enum':
if (!empty($field['length'])) { if (!empty($field['length'])) {
return 'NUMBER('.$field['length'].')'; return 'NUMBER('.$field['length'].')';
} }
return 'INT'; return 'INT';
case 'boolean': case 'boolean':
return 'NUMBER(1)'; return 'NUMBER(1)';
case 'date': case 'date':
case 'time': case 'time':
case 'timestamp': case 'timestamp':
return 'DATE'; return 'DATE';
case 'float': case 'float':
return 'NUMBER'; return 'NUMBER';
case 'decimal': case 'decimal':
return 'NUMBER(*,'.$db->options['decimal_places'].')'; return 'NUMBER(*,'.$db->options['decimal_places'].')';
} }
} }
/** /**
...@@ -104,46 +104,9 @@ class Doctrine_DataDict_Oracle extends Doctrine_DataDict ...@@ -104,46 +104,9 @@ class Doctrine_DataDict_Oracle extends Doctrine_DataDict
$length = $field['length']; $length = $field['length'];
} }
switch ($db_type) { switch ($db_type) {
case 'integer': case 'integer':
case 'pls_integer': case 'pls_integer':
case 'binary_integer': case 'binary_integer':
$type[] = 'integer';
if ($length == '1') {
$type[] = 'boolean';
if (preg_match('/^(is|has)/', $field['name'])) {
$type = array_reverse($type);
}
}
break;
case 'varchar':
case 'varchar2':
case 'nvarchar2':
$fixed = false;
case 'char':
case 'nchar':
$type[] = 'text';
if ($length == '1') {
$type[] = 'boolean';
if (preg_match('/^(is|has)/', $field['name'])) {
$type = array_reverse($type);
}
}
if ($fixed !== false) {
$fixed = true;
}
break;
case 'date':
case 'timestamp':
$type[] = 'timestamp';
$length = null;
break;
case 'float':
$type[] = 'float';
break;
case 'number':
if (!empty($field['scale'])) {
$type[] = 'decimal';
} else {
$type[] = 'integer'; $type[] = 'integer';
if ($length == '1') { if ($length == '1') {
$type[] = 'boolean'; $type[] = 'boolean';
...@@ -151,25 +114,62 @@ class Doctrine_DataDict_Oracle extends Doctrine_DataDict ...@@ -151,25 +114,62 @@ class Doctrine_DataDict_Oracle extends Doctrine_DataDict
$type = array_reverse($type); $type = array_reverse($type);
} }
} }
} break;
break; case 'varchar':
case 'long': case 'varchar2':
$type[] = 'text'; case 'nvarchar2':
case 'clob': $fixed = false;
case 'nclob': case 'char':
$type[] = 'clob'; case 'nchar':
$type[] = 'text';
if ($length == '1') {
$type[] = 'boolean';
if (preg_match('/^(is|has)/', $field['name'])) {
$type = array_reverse($type);
}
}
if ($fixed !== false) {
$fixed = true;
}
break;
case 'date':
case 'timestamp':
$type[] = 'timestamp';
$length = null;
break;
case 'float':
$type[] = 'float';
break;
case 'number':
if (!empty($field['scale'])) {
$type[] = 'decimal';
} else {
$type[] = 'integer';
if ($length == '1') {
$type[] = 'boolean';
if (preg_match('/^(is|has)/', $field['name'])) {
$type = array_reverse($type);
}
}
}
break;
case 'long':
$type[] = 'text';
case 'clob':
case 'nclob':
$type[] = 'clob';
break;
case 'blob':
case 'raw':
case 'long raw':
case 'bfile':
$type[] = 'blob';
$length = null;
break; break;
case 'blob': case 'rowid':
case 'raw': case 'urowid':
case 'long raw': default:
case 'bfile': throw new Doctrine_DataDict_Oracle_Exception('unknown database attribute type: '.$db_type);
$type[] = 'blob';
$length = null;
break;
case 'rowid':
case 'urowid':
default:
throw new Doctrine_DataDict_Oracle_Exception('unknown database attribute type: '.$db_type);
} }
return array($type, $length, $unsigned, $fixed); return array($type, $length, $unsigned, $fixed);
......
...@@ -359,60 +359,60 @@ class Doctrine_DataDict_Pgsql extends Doctrine_DataDict ...@@ -359,60 +359,60 @@ class Doctrine_DataDict_Pgsql extends Doctrine_DataDict
public function getNativeDeclaration(array $field) public function getNativeDeclaration(array $field)
{ {
switch ($field['type']) { switch ($field['type']) {
case 'char': case 'char':
case 'string': case 'string':
case 'array': case 'array':
case 'object': case 'object':
case 'varchar': case 'varchar':
$length = (isset($field['length']) && $field['length']) ? $field['length'] : null; $length = (isset($field['length']) && $field['length']) ? $field['length'] : null;
// TODO: $db->options['default_text_field_length']; // TODO: $db->options['default_text_field_length'];
$fixed = ((isset($field['fixed']) && $field['fixed']) || $field['type'] == 'char') ? true : false; $fixed = ((isset($field['fixed']) && $field['fixed']) || $field['type'] == 'char') ? true : false;
return $fixed ? ($length ? 'CHAR('.$length.')' : 'CHAR('.$db->options['default_text_field_length'].')') return $fixed ? ($length ? 'CHAR('.$length.')' : 'CHAR('.$db->options['default_text_field_length'].')')
: ($length ? 'VARCHAR('.$length.')' : 'TEXT'); : ($length ? 'VARCHAR('.$length.')' : 'TEXT');
case 'clob': case 'clob':
return 'TEXT'; return 'TEXT';
case 'blob': case 'blob':
return 'BYTEA'; return 'BYTEA';
case 'enum': case 'enum':
case 'integer': case 'integer':
if (!empty($field['autoincrement'])) { if (!empty($field['autoincrement'])) {
if (!empty($field['length'])) {
$length = $field['length'];
if ($length > 4) {
return 'BIGSERIAL PRIMARY KEY';
}
}
return 'SERIAL PRIMARY KEY';
}
if (!empty($field['length'])) { if (!empty($field['length'])) {
$length = $field['length']; $length = $field['length'];
if ($length > 4) { if ($length <= 2) {
return 'BIGSERIAL PRIMARY KEY'; return 'SMALLINT';
} elseif ($length == 3 || $length == 4) {
return 'INT';
} elseif ($length > 4) {
return 'BIGINT';
} }
} }
return 'SERIAL PRIMARY KEY'; return 'INT';
} case 'boolean':
if (!empty($field['length'])) { return 'BOOLEAN';
$length = $field['length']; case 'date':
if ($length <= 2) { return 'DATE';
return 'SMALLINT'; case 'time':
} elseif ($length == 3 || $length == 4) { return 'TIME without time zone';
return 'INT'; case 'timestamp':
} elseif ($length > 4) { return 'TIMESTAMP without time zone';
return 'BIGINT'; case 'float':
} return 'FLOAT8';
} case 'decimal':
return 'INT'; $length = !empty($field['length']) ? $field['length'] : 18;
case 'boolean': return 'NUMERIC(' . $length . ',' . $this->conn->getAttribute(Doctrine::ATTR_DECIMAL_PLACES) . ')';
return 'BOOLEAN'; default:
case 'date': throw new Doctrine_DataDict_Pgsql_Exception('Unknown field type '. $field['type']);
return 'DATE';
case 'time':
return 'TIME without time zone';
case 'timestamp':
return 'TIMESTAMP without time zone';
case 'float':
return 'FLOAT8';
case 'decimal':
$length = !empty($field['length']) ? $field['length'] : 18;
return 'NUMERIC(' . $length . ',' . $this->conn->getAttribute(Doctrine::ATTR_DECIMAL_PLACES) . ')';
default:
throw new Doctrine_DataDict_Pgsql_Exception('Unknown field type '. $field['type']);
} }
} }
/** /**
...@@ -435,102 +435,102 @@ class Doctrine_DataDict_Pgsql extends Doctrine_DataDict ...@@ -435,102 +435,102 @@ class Doctrine_DataDict_Pgsql extends Doctrine_DataDict
$type = array(); $type = array();
$unsigned = $fixed = null; $unsigned = $fixed = null;
switch (strtolower($field['type'])) { switch (strtolower($field['type'])) {
case 'smallint': case 'smallint':
case 'int2': case 'int2':
$type[] = 'integer'; $type[] = 'integer';
$unsigned = false; $unsigned = false;
$length = 2; $length = 2;
if ($length == '2') { if ($length == '2') {
$type[] = 'boolean'; $type[] = 'boolean';
if (preg_match('/^(is|has)/', $field['name'])) { if (preg_match('/^(is|has)/', $field['name'])) {
$type = array_reverse($type); $type = array_reverse($type);
}
} }
} break;
break; case 'int':
case 'int': case 'int4':
case 'int4': case 'integer':
case 'integer': case 'serial':
case 'serial': case 'serial4':
case 'serial4': $type[] = 'integer';
$type[] = 'integer'; $unsigned = false;
$unsigned = false; $length = 4;
$length = 4; break;
break; case 'bigint':
case 'bigint': case 'int8':
case 'int8': case 'bigserial':
case 'bigserial': case 'serial8':
case 'serial8': $type[] = 'integer';
$type[] = 'integer'; $unsigned = false;
$unsigned = false; $length = 8;
$length = 8; break;
break; case 'bool':
case 'bool': case 'boolean':
case 'boolean':
$type[] = 'boolean';
$length = 1;
break;
case 'text':
case 'varchar':
$fixed = false;
case 'unknown':
case 'char':
case 'bpchar':
$type[] = 'text';
if ($length == '1') {
$type[] = 'boolean'; $type[] = 'boolean';
if (preg_match('/^(is|has)/', $field['name'])) { $length = 1;
$type = array_reverse($type); break;
case 'text':
case 'varchar':
$fixed = false;
case 'unknown':
case 'char':
case 'bpchar':
$type[] = 'text';
if ($length == '1') {
$type[] = 'boolean';
if (preg_match('/^(is|has)/', $field['name'])) {
$type = array_reverse($type);
}
} elseif (strstr($db_type, 'text')) {
$type[] = 'clob';
}
if ($fixed !== false) {
$fixed = true;
} }
} elseif (strstr($db_type, 'text')) { break;
case 'date':
$type[] = 'date';
$length = null;
break;
case 'datetime':
case 'timestamp':
$type[] = 'timestamp';
$length = null;
break;
case 'time':
$type[] = 'time';
$length = null;
break;
case 'float':
case 'double':
case 'real':
$type[] = 'float';
break;
case 'decimal':
case 'money':
case 'numeric':
$type[] = 'decimal';
break;
case 'tinyblob':
case 'mediumblob':
case 'longblob':
case 'blob':
case 'bytea':
$type[] = 'blob';
$length = null;
break;
case 'oid':
$type[] = 'blob';
$type[] = 'clob'; $type[] = 'clob';
} $length = null;
if ($fixed !== false) { break;
$fixed = true; case 'year':
} $type[] = 'integer';
break; $type[] = 'date';
case 'date': $length = null;
$type[] = 'date'; break;
$length = null; default:
break; throw new Doctrine_DataDict_Pgsql_Exception('unknown database attribute type: '.$db_type);
case 'datetime':
case 'timestamp':
$type[] = 'timestamp';
$length = null;
break;
case 'time':
$type[] = 'time';
$length = null;
break;
case 'float':
case 'double':
case 'real':
$type[] = 'float';
break;
case 'decimal':
case 'money':
case 'numeric':
$type[] = 'decimal';
break;
case 'tinyblob':
case 'mediumblob':
case 'longblob':
case 'blob':
case 'bytea':
$type[] = 'blob';
$length = null;
break;
case 'oid':
$type[] = 'blob';
$type[] = 'clob';
$length = null;
break;
case 'year':
$type[] = 'integer';
$type[] = 'date';
$length = null;
break;
default:
throw new Doctrine_DataDict_Pgsql_Exception('unknown database attribute type: '.$db_type);
} }
return array($type, $length, $unsigned, $fixed); return array($type, $length, $unsigned, $fixed);
......
...@@ -57,60 +57,60 @@ class Doctrine_DataDict_Sqlite extends Doctrine_DataDict ...@@ -57,60 +57,60 @@ class Doctrine_DataDict_Sqlite extends Doctrine_DataDict
public function getNativeDeclaration(array $field) public function getNativeDeclaration(array $field)
{ {
switch ($field['type']) { switch ($field['type']) {
case 'text': case 'text':
case 'object': case 'object':
case 'array': case 'array':
case 'string': case 'string':
case 'char': case 'char':
case 'gzip': case 'gzip':
case 'varchar': case 'varchar':
$length = (isset($field['length']) && $field['length']) ? $field['length'] : null; $length = (isset($field['length']) && $field['length']) ? $field['length'] : null;
$fixed = ((isset($field['fixed']) && $field['fixed']) || $field['type'] == 'char') ? true : false; $fixed = ((isset($field['fixed']) && $field['fixed']) || $field['type'] == 'char') ? true : false;
return $fixed ? ($length ? 'CHAR('.$length.')' : 'CHAR('.$this->conn->getAttribute(Doctrine::ATTR_DEFAULT_TEXTFLD_LENGTH).')') return $fixed ? ($length ? 'CHAR('.$length.')' : 'CHAR('.$this->conn->getAttribute(Doctrine::ATTR_DEFAULT_TEXTFLD_LENGTH).')')
: ($length ? 'VARCHAR('.$length.')' : 'TEXT'); : ($length ? 'VARCHAR('.$length.')' : 'TEXT');
case 'clob': case 'clob':
if (!empty($field['length'])) { if (!empty($field['length'])) {
$length = $field['length']; $length = $field['length'];
if ($length <= 255) { if ($length <= 255) {
return 'TINYTEXT'; return 'TINYTEXT';
} elseif ($length <= 65535) { } elseif ($length <= 65535) {
return 'TEXT'; return 'TEXT';
} elseif ($length <= 16777215) { } elseif ($length <= 16777215) {
return 'MEDIUMTEXT'; return 'MEDIUMTEXT';
}
} }
} return 'LONGTEXT';
return 'LONGTEXT'; case 'blob':
case 'blob': if (!empty($field['length'])) {
if (!empty($field['length'])) { $length = $field['length'];
$length = $field['length']; if ($length <= 255) {
if ($length <= 255) { return 'TINYBLOB';
return 'TINYBLOB'; } elseif ($length <= 65535) {
} elseif ($length <= 65535) { return 'BLOB';
return 'BLOB'; } elseif ($length <= 16777215) {
} elseif ($length <= 16777215) { return 'MEDIUMBLOB';
return 'MEDIUMBLOB'; }
} }
} return 'LONGBLOB';
return 'LONGBLOB'; case 'enum':
case 'enum': case 'integer':
case 'integer': case 'boolean':
case 'boolean': return 'INTEGER';
return 'INTEGER'; case 'date':
case 'date': return 'DATE';
return 'DATE'; case 'time':
case 'time': return 'TIME';
return 'TIME'; case 'timestamp':
case 'timestamp': return 'DATETIME';
return 'DATETIME'; case 'float':
case 'float': case 'double':
case 'double': return 'DOUBLE';//($db->options['fixed_float'] ? '('.
return 'DOUBLE';//($db->options['fixed_float'] ? '('. //($db->options['fixed_float']+2).','.$db->options['fixed_float'].')' : '');
//($db->options['fixed_float']+2).','.$db->options['fixed_float'].')' : ''); case 'decimal':
case 'decimal': $length = !empty($field['length']) ? $field['length'] : 18;
$length = !empty($field['length']) ? $field['length'] : 18; return 'DECIMAL('.$length.','.$db->options['decimal_places'].')';
return 'DECIMAL('.$length.','.$db->options['decimal_places'].')';
} }
throw new Doctrine_DataDict_Sqlite_Exception('Unknown datatype ' . $field['type']); throw new Doctrine_DataDict_Sqlite_Exception('Unknown datatype ' . $field['type']);
} }
...@@ -128,101 +128,101 @@ class Doctrine_DataDict_Sqlite extends Doctrine_DataDict ...@@ -128,101 +128,101 @@ class Doctrine_DataDict_Sqlite extends Doctrine_DataDict
$fixed = null; $fixed = null;
$type = array(); $type = array();
switch ($dbType) { switch ($dbType) {
case 'boolean': case 'boolean':
$type[] = 'boolean'; $type[] = 'boolean';
break; break;
case 'tinyint': case 'tinyint':
$type[] = 'integer'; $type[] = 'integer';
$type[] = 'boolean';
if (preg_match('/^(is|has)/', $field['name'])) {
$type = array_reverse($type);
}
$unsigned = preg_match('/ unsigned/i', $field['type']);
$length = 1;
break;
case 'smallint':
$type[] = 'integer';
$unsigned = preg_match('/ unsigned/i', $field['type']);
$length = 2;
break;
case 'mediumint':
$type[] = 'integer';
$unsigned = preg_match('/ unsigned/i', $field['type']);
$length = 3;
break;
case 'int':
case 'integer':
case 'serial':
$type[] = 'integer';
$unsigned = preg_match('/ unsigned/i', $field['type']);
$length = 4;
break;
case 'bigint':
case 'bigserial':
$type[] = 'integer';
$unsigned = preg_match('/ unsigned/i', $field['type']);
$length = 8;
break;
case 'clob':
case 'tinytext':
case 'mediumtext':
case 'longtext':
case 'text':
case 'varchar':
case 'varchar2':
$fixed = false;
case 'char':
$type[] = 'text';
if ($length == '1') {
$type[] = 'boolean'; $type[] = 'boolean';
if (preg_match('/^(is|has)/', $field['name'])) { if (preg_match('/^(is|has)/', $field['name'])) {
$type = array_reverse($type); $type = array_reverse($type);
} }
} elseif (strstr($dbType, 'text')) { $unsigned = preg_match('/ unsigned/i', $field['type']);
$type[] = 'clob'; $length = 1;
} break;
if ($fixed !== false) { case 'smallint':
$fixed = true; $type[] = 'integer';
} $unsigned = preg_match('/ unsigned/i', $field['type']);
break; $length = 2;
case 'date': break;
$type[] = 'date'; case 'mediumint':
$length = null; $type[] = 'integer';
break; $unsigned = preg_match('/ unsigned/i', $field['type']);
case 'datetime': $length = 3;
case 'timestamp': break;
$type[] = 'timestamp'; case 'int':
$length = null; case 'integer':
break; case 'serial':
case 'time': $type[] = 'integer';
$type[] = 'time'; $unsigned = preg_match('/ unsigned/i', $field['type']);
$length = null; $length = 4;
break; break;
case 'float': case 'bigint':
case 'double': case 'bigserial':
case 'real': $type[] = 'integer';
$type[] = 'float'; $unsigned = preg_match('/ unsigned/i', $field['type']);
$length = null; $length = 8;
break; break;
case 'decimal': case 'clob':
case 'numeric': case 'tinytext':
$type[] = 'decimal'; case 'mediumtext':
$length = null; case 'longtext':
break; case 'text':
case 'tinyblob': case 'varchar':
case 'mediumblob': case 'varchar2':
case 'longblob': $fixed = false;
case 'blob': case 'char':
$type[] = 'blob'; $type[] = 'text';
$length = null; if ($length == '1') {
break; $type[] = 'boolean';
case 'year': if (preg_match('/^(is|has)/', $field['name'])) {
$type[] = 'integer'; $type = array_reverse($type);
$type[] = 'date'; }
$length = null; } elseif (strstr($dbType, 'text')) {
break; $type[] = 'clob';
default: }
throw new Doctrine_DataDict_Sqlite_Exception('unknown database attribute type: '.$dbType); if ($fixed !== false) {
$fixed = true;
}
break;
case 'date':
$type[] = 'date';
$length = null;
break;
case 'datetime':
case 'timestamp':
$type[] = 'timestamp';
$length = null;
break;
case 'time':
$type[] = 'time';
$length = null;
break;
case 'float':
case 'double':
case 'real':
$type[] = 'float';
$length = null;
break;
case 'decimal':
case 'numeric':
$type[] = 'decimal';
$length = null;
break;
case 'tinyblob':
case 'mediumblob':
case 'longblob':
case 'blob':
$type[] = 'blob';
$length = null;
break;
case 'year':
$type[] = 'integer';
$type[] = 'date';
$length = null;
break;
default:
throw new Doctrine_DataDict_Sqlite_Exception('unknown database attribute type: '.$dbType);
} }
return array($type, $length, $unsigned, $fixed); return array($type, $length, $unsigned, $fixed);
......
...@@ -247,33 +247,33 @@ class Doctrine_Db implements Countable, IteratorAggregate, Doctrine_Adapter_Inte ...@@ -247,33 +247,33 @@ class Doctrine_Db implements Countable, IteratorAggregate, Doctrine_Adapter_Inte
throw new Doctrine_Db_Exception('Driver '.$parts['scheme'].' not availible or extension not loaded'); throw new Doctrine_Db_Exception('Driver '.$parts['scheme'].' not availible or extension not loaded');
} }
switch ($parts['scheme']) { switch ($parts['scheme']) {
case 'sqlite': case 'sqlite':
if (isset($parts['host']) && $parts['host'] == ':memory') { if (isset($parts['host']) && $parts['host'] == ':memory') {
$parts['database'] = ':memory:'; $parts['database'] = ':memory:';
$parts['dsn'] = 'sqlite::memory:'; $parts['dsn'] = 'sqlite::memory:';
} }
break; break;
case 'mysql': case 'mysql':
case 'informix': case 'informix':
case 'oci8': case 'oci8':
case 'mssql': case 'mssql':
case 'firebird': case 'firebird':
case 'pgsql': case 'pgsql':
case 'odbc': case 'odbc':
if ( ! isset($parts['path']) || $parts['path'] == '/') { if ( ! isset($parts['path']) || $parts['path'] == '/') {
throw new Doctrine_Db_Exception('No database availible in data source name'); throw new Doctrine_Db_Exception('No database availible in data source name');
} }
if (isset($parts['path'])) { if (isset($parts['path'])) {
$parts['database'] = substr($parts['path'], 1); $parts['database'] = substr($parts['path'], 1);
} }
if ( ! isset($parts['host'])) { if ( ! isset($parts['host'])) {
throw new Doctrine_Db_Exception('No hostname set in data source name'); throw new Doctrine_Db_Exception('No hostname set in data source name');
} }
$parts['dsn'] = $parts["scheme"].":host=".$parts["host"].";dbname=".$parts["database"]; $parts['dsn'] = $parts["scheme"].":host=".$parts["host"].";dbname=".$parts["database"];
break; break;
default: default:
throw new Doctrine_Db_Exception('Unknown driver '.$parts['scheme']); throw new Doctrine_Db_Exception('Unknown driver '.$parts['scheme']);
} }
return $parts; return $parts;
......
...@@ -189,25 +189,25 @@ class Doctrine_Export_Firebird extends Doctrine_Export ...@@ -189,25 +189,25 @@ class Doctrine_Export_Firebird extends Doctrine_Export
{ {
foreach ($changes as $change_name => $change) { foreach ($changes as $change_name => $change) {
switch ($change_name) { switch ($change_name) {
case 'notnull': case 'notnull':
return $db->raiseError(MDB2_ERROR_UNSUPPORTED, null, null, return $db->raiseError(MDB2_ERROR_UNSUPPORTED, null, null,
'it is not supported changes to field not null constraint', __FUNCTION__); 'it is not supported changes to field not null constraint', __FUNCTION__);
case 'default': case 'default':
return $db->raiseError(MDB2_ERROR_UNSUPPORTED, null, null, return $db->raiseError(MDB2_ERROR_UNSUPPORTED, null, null,
'it is not supported changes to field default value', __FUNCTION__); 'it is not supported changes to field default value', __FUNCTION__);
case 'length': case 'length':
/* /*
return $db->raiseError(MDB2_ERROR_UNSUPPORTED, null, null, return $db->raiseError(MDB2_ERROR_UNSUPPORTED, null, null,
'it is not supported changes to field default length', __FUNCTION__); 'it is not supported changes to field default length', __FUNCTION__);
*/ */
case 'unsigned': case 'unsigned':
case 'type': case 'type':
case 'declaration': case 'declaration':
case 'definition': case 'definition':
break; break;
default: default:
return $db->raiseError(MDB2_ERROR_UNSUPPORTED, null, null, return $db->raiseError(MDB2_ERROR_UNSUPPORTED, null, null,
'it is not supported change of type' . $change_name, __FUNCTION__); 'it is not supported change of type' . $change_name, __FUNCTION__);
} }
} }
return MDB2_OK; return MDB2_OK;
...@@ -320,20 +320,20 @@ class Doctrine_Export_Firebird extends Doctrine_Export ...@@ -320,20 +320,20 @@ class Doctrine_Export_Firebird extends Doctrine_Export
{ {
foreach ($changes as $change_name => $change) { foreach ($changes as $change_name => $change) {
switch ($change_name) { switch ($change_name) {
case 'add': case 'add':
case 'remove': case 'remove':
case 'rename': case 'rename':
break; break;
case 'change': case 'change':
foreach ($changes['change'] as $field) { foreach ($changes['change'] as $field) {
if (PEAR::isError($err = $this->checkSupportedChanges($field))) { if (PEAR::isError($err = $this->checkSupportedChanges($field))) {
return $err; return $err;
}
} }
} break;
break; default:
default: return $db->raiseError(MDB2_ERROR_CANNOT_ALTER, null, null,
return $db->raiseError(MDB2_ERROR_CANNOT_ALTER, null, null, 'change type ' . $change_name . ' not yet supported', __FUNCTION__);
'change type ' . $change_name . ' not yet supported', __FUNCTION__);
} }
} }
if ($check) { if ($check) {
...@@ -432,12 +432,12 @@ class Doctrine_Export_Firebird extends Doctrine_Export ...@@ -432,12 +432,12 @@ class Doctrine_Export_Firebird extends Doctrine_Export
foreach ($definition['fields'] as $field) { foreach ($definition['fields'] as $field) {
if (!strcmp($query_sort, '') && isset($field['sorting'])) { if (!strcmp($query_sort, '') && isset($field['sorting'])) {
switch ($field['sorting']) { switch ($field['sorting']) {
case 'ascending': case 'ascending':
$query_sort = ' ASC'; $query_sort = ' ASC';
break; break;
case 'descending': case 'descending':
$query_sort = ' DESC'; $query_sort = ' DESC';
break; break;
} }
} }
} }
......
...@@ -154,16 +154,16 @@ class Doctrine_Export_Mssql extends Doctrine_Export ...@@ -154,16 +154,16 @@ class Doctrine_Export_Mssql extends Doctrine_Export
{ {
foreach ($changes as $change_name => $change) { foreach ($changes as $change_name => $change) {
switch ($change_name) { switch ($change_name) {
case 'add': case 'add':
break; break;
case 'remove': case 'remove':
break; break;
case 'name': case 'name':
case 'rename': case 'rename':
case 'change': case 'change':
default: default:
return $db->raiseError(Doctrine::ERR_CANNOT_ALTER, null, null, return $db->raiseError(Doctrine::ERR_CANNOT_ALTER, null, null,
'alterTable: change type "'.$change_name.'" not yet supported'); 'alterTable: change type "'.$change_name.'" not yet supported');
} }
} }
......
...@@ -236,7 +236,7 @@ class Doctrine_Export_Mysql extends Doctrine_Export ...@@ -236,7 +236,7 @@ class Doctrine_Export_Mysql extends Doctrine_Export
case 'change': case 'change':
case 'rename': case 'rename':
case 'name': case 'name':
break; break;
default: default:
throw new Doctrine_Export_Mysql_Exception('change type "'.$changeName.'" not yet supported'); throw new Doctrine_Export_Mysql_Exception('change type "'.$changeName.'" not yet supported');
} }
......
...@@ -343,15 +343,15 @@ END; ...@@ -343,15 +343,15 @@ END;
foreach ($changes as $changeName => $change) { foreach ($changes as $changeName => $change) {
switch ($changeName) { switch ($changeName) {
case 'add': case 'add':
case 'remove': case 'remove':
case 'change': case 'change':
case 'name': case 'name':
case 'rename': case 'rename':
break; break;
default: default:
return $this->conn->raiseError(MDB2_ERROR_CANNOT_ALTER, null, null, return $this->conn->raiseError(MDB2_ERROR_CANNOT_ALTER, null, null,
'change type "'.$changeName.'" not yet supported', __FUNCTION__); 'change type "'.$changeName.'" not yet supported', __FUNCTION__);
} }
} }
......
...@@ -155,7 +155,7 @@ class Doctrine_Export_Pgsql extends Doctrine_Export ...@@ -155,7 +155,7 @@ class Doctrine_Export_Pgsql extends Doctrine_Export
case 'change': case 'change':
case 'name': case 'name':
case 'rename': case 'rename':
break; break;
default: default:
throw new Doctrine_Export_Pgsql_Exception('change type "'.$change_name.'\" not yet supported'); throw new Doctrine_Export_Pgsql_Exception('change type "'.$change_name.'\" not yet supported');
} }
......
...@@ -75,12 +75,12 @@ class Doctrine_Export_Sqlite extends Doctrine_Export ...@@ -75,12 +75,12 @@ class Doctrine_Export_Sqlite extends Doctrine_Export
$fieldString = $fieldName; $fieldString = $fieldName;
if (isset($field['sorting'])) { if (isset($field['sorting'])) {
switch ($field['sorting']) { switch ($field['sorting']) {
case 'ascending': case 'ascending':
$fieldString .= ' ASC'; $fieldString .= ' ASC';
break; break;
case 'descending': case 'descending':
$fieldString .= ' DESC'; $fieldString .= ' DESC';
break; break;
} }
} }
$fields[] = $fieldString; $fields[] = $fieldString;
......
...@@ -45,11 +45,11 @@ class Doctrine_Expression_Mssql extends Doctrine_Expression ...@@ -45,11 +45,11 @@ class Doctrine_Expression_Mssql extends Doctrine_Expression
public function now($type = 'timestamp') public function now($type = 'timestamp')
{ {
switch ($type) { switch ($type) {
case 'time': case 'time':
case 'date': case 'date':
case 'timestamp': case 'timestamp':
default: default:
return 'GETDATE()'; return 'GETDATE()';
} }
} }
/** /**
......
...@@ -65,16 +65,16 @@ class Doctrine_Expression_Mysql extends Doctrine_Expression ...@@ -65,16 +65,16 @@ class Doctrine_Expression_Mysql extends Doctrine_Expression
$field = is_null($field) ? '' : $field.' '; $field = is_null($field) ? '' : $field.' ';
$operator = strtoupper($operator); $operator = strtoupper($operator);
switch ($operator) { switch ($operator) {
// case insensitive // case insensitive
case 'ILIKE': case 'ILIKE':
$match = $field.'LIKE '; $match = $field.'LIKE ';
break; break;
// case sensitive // case sensitive
case 'LIKE': case 'LIKE':
$match = $field.'LIKE BINARY '; $match = $field.'LIKE BINARY ';
break; break;
default: default:
throw new Doctrine_Expression_Mysql_Exception('not a supported operator type:'. $operator); throw new Doctrine_Expression_Mysql_Exception('not a supported operator type:'. $operator);
} }
} }
$match.= "'"; $match.= "'";
......
...@@ -77,11 +77,11 @@ class Doctrine_Expression_Oracle extends Doctrine_Expression ...@@ -77,11 +77,11 @@ class Doctrine_Expression_Oracle extends Doctrine_Expression
public function now($type = 'timestamp') public function now($type = 'timestamp')
{ {
switch ($type) { switch ($type) {
case 'date': case 'date':
case 'time': case 'time':
case 'timestamp': case 'timestamp':
default: default:
return 'TO_CHAR(CURRENT_TIMESTAMP, \'YYYY-MM-DD HH24:MI:SS\')'; return 'TO_CHAR(CURRENT_TIMESTAMP, \'YYYY-MM-DD HH24:MI:SS\')';
} }
} }
/** /**
......
...@@ -142,17 +142,17 @@ class Doctrine_Expression_Pgsql extends Doctrine_Expression ...@@ -142,17 +142,17 @@ class Doctrine_Expression_Pgsql extends Doctrine_Expression
$field = is_null($field) ? '' : $field.' '; $field = is_null($field) ? '' : $field.' ';
$operator = strtoupper($operator); $operator = strtoupper($operator);
switch ($operator) { switch ($operator) {
// case insensitive // case insensitive
case 'ILIKE': case 'ILIKE':
$match = $field.'ILIKE '; $match = $field.'ILIKE ';
break; break;
// case sensitive // case sensitive
case 'LIKE': case 'LIKE':
$match = $field.'LIKE '; $match = $field.'LIKE ';
break; break;
default: default:
return $db->raiseError(MDB2_ERROR_UNSUPPORTED, null, null, return $db->raiseError(MDB2_ERROR_UNSUPPORTED, null, null,
'not a supported operator type:'. $operator, __FUNCTION__); 'not a supported operator type:'. $operator, __FUNCTION__);
} }
} }
$match.= "'"; $match.= "'";
......
...@@ -125,13 +125,13 @@ class Doctrine_Expression_Sqlite extends Doctrine_Expression ...@@ -125,13 +125,13 @@ class Doctrine_Expression_Sqlite extends Doctrine_Expression
public function now($type = 'timestamp') public function now($type = 'timestamp')
{ {
switch ($type) { switch ($type) {
case 'time': case 'time':
return 'time(\'now\')'; return 'time(\'now\')';
case 'date': case 'date':
return 'date(\'now\')'; return 'date(\'now\')';
case 'timestamp': case 'timestamp':
default: default:
return 'datetime(\'now\')'; return 'datetime(\'now\')';
} }
} }
/** /**
......
...@@ -323,23 +323,23 @@ abstract class Doctrine_Hydrate extends Doctrine_Access ...@@ -323,23 +323,23 @@ abstract class Doctrine_Hydrate extends Doctrine_Access
return new Doctrine_Collection($table); return new Doctrine_Collection($table);
} }
switch ($this->fetchModes[$name]) { switch ($this->fetchModes[$name]) {
case Doctrine::FETCH_BATCH: case Doctrine::FETCH_BATCH:
$coll = new Doctrine_Collection_Batch($table); $coll = new Doctrine_Collection_Batch($table);
break; break;
case Doctrine::FETCH_LAZY: case Doctrine::FETCH_LAZY:
$coll = new Doctrine_Collection_Lazy($table); $coll = new Doctrine_Collection_Lazy($table);
break; break;
case Doctrine::FETCH_OFFSET: case Doctrine::FETCH_OFFSET:
$coll = new Doctrine_Collection_Offset($table); $coll = new Doctrine_Collection_Offset($table);
break; break;
case Doctrine::FETCH_IMMEDIATE: case Doctrine::FETCH_IMMEDIATE:
$coll = new Doctrine_Collection_Immediate($table); $coll = new Doctrine_Collection_Immediate($table);
break; break;
case Doctrine::FETCH_LAZY_OFFSET: case Doctrine::FETCH_LAZY_OFFSET:
$coll = new Doctrine_Collection_LazyOffset($table); $coll = new Doctrine_Collection_LazyOffset($table);
break; break;
default: default:
throw new Doctrine_Exception("Unknown fetchmode"); throw new Doctrine_Exception("Unknown fetchmode");
}; };
return $coll; return $coll;
......
...@@ -39,21 +39,21 @@ class Doctrine_Lib ...@@ -39,21 +39,21 @@ class Doctrine_Lib
public static function getRecordStateAsString($state) public static function getRecordStateAsString($state)
{ {
switch ($state) { switch ($state) {
case Doctrine_Record::STATE_PROXY: case Doctrine_Record::STATE_PROXY:
return "proxy"; return "proxy";
break; break;
case Doctrine_Record::STATE_CLEAN: case Doctrine_Record::STATE_CLEAN:
return "persistent clean"; return "persistent clean";
break; break;
case Doctrine_Record::STATE_DIRTY: case Doctrine_Record::STATE_DIRTY:
return "persistent dirty"; return "persistent dirty";
break; break;
case Doctrine_Record::STATE_TDIRTY: case Doctrine_Record::STATE_TDIRTY:
return "transient dirty"; return "transient dirty";
break; break;
case Doctrine_Record::STATE_TCLEAN: case Doctrine_Record::STATE_TCLEAN:
return "transient clean"; return "transient clean";
break; break;
}; };
} }
/** /**
...@@ -80,15 +80,15 @@ class Doctrine_Lib ...@@ -80,15 +80,15 @@ class Doctrine_Lib
public static function getConnectionStateAsString($state) public static function getConnectionStateAsString($state)
{ {
switch ($state) { switch ($state) {
case Doctrine_Transaction::STATE_SLEEP: case Doctrine_Transaction::STATE_SLEEP:
return "open"; return "open";
break; break;
case Doctrine_Transaction::STATE_BUSY: case Doctrine_Transaction::STATE_BUSY:
return "busy"; return "busy";
break; break;
case Doctrine_Transaction::STATE_ACTIVE: case Doctrine_Transaction::STATE_ACTIVE:
return "active"; return "active";
break; break;
}; };
} }
/** /**
......
...@@ -192,33 +192,33 @@ class Doctrine_Manager extends Doctrine_Configurable implements Countable, Itera ...@@ -192,33 +192,33 @@ class Doctrine_Manager extends Doctrine_Configurable implements Countable, Itera
$this->index++; $this->index++;
} }
switch ($adapter->getAttribute(PDO::ATTR_DRIVER_NAME)) { switch ($adapter->getAttribute(PDO::ATTR_DRIVER_NAME)) {
case 'mysql': case 'mysql':
$this->connections[$name] = new Doctrine_Connection_Mysql($this, $adapter); $this->connections[$name] = new Doctrine_Connection_Mysql($this, $adapter);
break; break;
case 'sqlite': case 'sqlite':
$this->connections[$name] = new Doctrine_Connection_Sqlite($this, $adapter); $this->connections[$name] = new Doctrine_Connection_Sqlite($this, $adapter);
break; break;
case 'pgsql': case 'pgsql':
$this->connections[$name] = new Doctrine_Connection_Pgsql($this, $adapter); $this->connections[$name] = new Doctrine_Connection_Pgsql($this, $adapter);
break; break;
case 'oci': case 'oci':
case 'oracle': case 'oracle':
$this->connections[$name] = new Doctrine_Connection_Oracle($this, $adapter); $this->connections[$name] = new Doctrine_Connection_Oracle($this, $adapter);
break; break;
case 'mssql': case 'mssql':
$this->connections[$name] = new Doctrine_Connection_Mssql($this, $adapter); $this->connections[$name] = new Doctrine_Connection_Mssql($this, $adapter);
break; break;
case 'firebird': case 'firebird':
$this->connections[$name] = new Doctrine_Connection_Firebird($this, $adapter); $this->connections[$name] = new Doctrine_Connection_Firebird($this, $adapter);
break; break;
case 'informix': case 'informix':
$this->connections[$name] = new Doctrine_Connection_Informix($this, $adapter); $this->connections[$name] = new Doctrine_Connection_Informix($this, $adapter);
break; break;
case 'mock': case 'mock':
$this->connections[$name] = new Doctrine_Connection_Mock($this, $adapter); $this->connections[$name] = new Doctrine_Connection_Mock($this, $adapter);
break; break;
default: default:
throw new Doctrine_Manager_Exception('Unknown connection driver '. $adapter->getAttribute(PDO::ATTR_DRIVER_NAME)); throw new Doctrine_Manager_Exception('Unknown connection driver '. $adapter->getAttribute(PDO::ATTR_DRIVER_NAME));
}; };
$this->currIndex = $name; $this->currIndex = $name;
......
...@@ -48,10 +48,10 @@ class Doctrine_Query_From extends Doctrine_Query_Part ...@@ -48,10 +48,10 @@ class Doctrine_Query_From extends Doctrine_Query_Part
$operator = false; $operator = false;
switch (trim($parts[0])) { switch (trim($parts[0])) {
case 'INNER': case 'INNER':
$operator = ':'; $operator = ':';
case 'LEFT': case 'LEFT':
array_shift($parts); array_shift($parts);
} }
$last = ''; $last = '';
......
...@@ -64,24 +64,24 @@ class Doctrine_Query_Where extends Doctrine_Query_Condition ...@@ -64,24 +64,24 @@ class Doctrine_Query_Where extends Doctrine_Query_Condition
$stack = $this->query->getTableStack(); $stack = $this->query->getTableStack();
switch ($func) { switch ($func) {
case 'contains': case 'contains':
case 'regexp': case 'regexp':
case 'like': case 'like':
$operator = $this->getOperator($func); $operator = $this->getOperator($func);
if (empty($relation)) { if (empty($relation)) {
throw new Doctrine_Query_Exception('DQL functions contains/regexp/like can only be used for fields of related components'); throw new Doctrine_Query_Exception('DQL functions contains/regexp/like can only be used for fields of related components');
} }
$where = array(); $where = array();
foreach ($values as $value) { foreach ($values as $value) {
$where[] = $alias.'.'.$relation->getLocal(). $where[] = $alias.'.'.$relation->getLocal().
' IN (SELECT '.$relation->getForeign(). ' IN (SELECT '.$relation->getForeign().
' FROM '.$relation->getTable()->getTableName().' WHERE '.$field.$operator.$value.')'; ' FROM '.$relation->getTable()->getTableName().' WHERE '.$field.$operator.$value.')';
} }
$where = implode(' AND ', $where); $where = implode(' AND ', $where);
break; break;
default: default:
throw new Doctrine_Query_Exception('Unknown DQL function: '.$func); throw new Doctrine_Query_Exception('Unknown DQL function: '.$func);
} }
} else { } else {
$table = $this->query->load($reference, false); $table = $this->query->load($reference, false);
...@@ -124,15 +124,15 @@ class Doctrine_Query_Where extends Doctrine_Query_Condition ...@@ -124,15 +124,15 @@ class Doctrine_Query_Where extends Doctrine_Query_Condition
} }
switch ($operator) { switch ($operator) {
case '<': case '<':
case '>': case '>':
case '=': case '=':
case '!=': case '!=':
if ($enumIndex !== false) { if ($enumIndex !== false) {
$value = $enumIndex; $value = $enumIndex;
} }
default: default:
$where = $alias.'.'.$field.' '.$operator.' '.$value; $where = $alias.'.'.$field.' '.$operator.' '.$value;
} }
} }
} }
...@@ -202,15 +202,15 @@ class Doctrine_Query_Where extends Doctrine_Query_Condition ...@@ -202,15 +202,15 @@ class Doctrine_Query_Where extends Doctrine_Query_Condition
public function getOperator($func) public function getOperator($func)
{ {
switch ($func) { switch ($func) {
case 'contains': case 'contains':
$operator = ' = '; $operator = ' = ';
break; break;
case 'regexp': case 'regexp':
$operator = $this->query->getConnection()->getRegexpOperator(); $operator = $this->query->getConnection()->getRegexpOperator();
break; break;
case 'like': case 'like':
$operator = ' LIKE '; $operator = ' LIKE ';
break; break;
} }
return $operator; return $operator;
} }
......
...@@ -87,37 +87,37 @@ class Doctrine_RawSql extends Doctrine_Hydrate ...@@ -87,37 +87,37 @@ class Doctrine_RawSql extends Doctrine_Hydrate
foreach ($e as $k => $part) { foreach ($e as $k => $part) {
$low = strtolower($part); $low = strtolower($part);
switch (strtolower($part)) { switch (strtolower($part)) {
case "select": case "select":
case "from": case "from":
case "where": case "where":
case "limit": case "limit":
case "offset": case "offset":
case "having": case "having":
$p = $low;
if ( ! isset($parts[$low])) {
$parts[$low] = array();
}
break;
case "order":
case "group":
$i = ($k + 1);
if (isset($e[$i]) && strtolower($e[$i]) === "by") {
$p = $low; $p = $low;
$p .= "by"; if ( ! isset($parts[$low])) {
$parts[$low."by"] = array(); $parts[$low] = array();
}
} else { break;
$parts[$p][] = $part; case "order":
} case "group":
break; $i = ($k + 1);
case "by": if (isset($e[$i]) && strtolower($e[$i]) === "by") {
continue; $p = $low;
default: $p .= "by";
if ( ! isset($parts[$p][0])) { $parts[$low."by"] = array();
$parts[$p][0] = $part;
} else { } else {
$parts[$p][0] .= ' '.$part; $parts[$p][] = $part;
} }
break;
case "by":
continue;
default:
if ( ! isset($parts[$p][0])) {
$parts[$p][0] = $part;
} else {
$parts[$p][0] .= ' '.$part;
}
}; };
}; };
......
...@@ -373,37 +373,35 @@ abstract class Doctrine_Record extends Doctrine_Access implements Countable, Ite ...@@ -373,37 +373,35 @@ abstract class Doctrine_Record extends Doctrine_Access implements Countable, Ite
$this->_data[$name] = self::$null; $this->_data[$name] = self::$null;
} else { } else {
switch ($type) { switch ($type) {
case "array": case "array":
case "object": case "object":
if ($tmp[$name] !== self::$null) {
if ($tmp[$name] !== self::$null) { if (is_string($tmp[$name])) {
if (is_string($tmp[$name])) { $value = unserialize($tmp[$name]);
$value = unserialize($tmp[$name]);
if ($value === false)
throw new Doctrine_Record_Exception("Unserialization of $name failed.");
} else {
$value = $tmp[$name];
}
$this->_data[$name] = $value;
}
break;
case "gzip":
if ($tmp[$name] !== self::$null) {
$value = gzuncompress($tmp[$name]);
if ($value === false) if ($value === false)
throw new Doctrine_Record_Exception("Unserialization of $name failed."); throw new Doctrine_Record_Exception("Uncompressing of $name failed.");
} else {
$value = $tmp[$name]; $this->_data[$name] = $value;
} }
$this->_data[$name] = $value; break;
} case "enum":
break; $this->_data[$name] = $this->_table->enumValue($name, $tmp[$name]);
case "gzip": break;
default:
if ($tmp[$name] !== self::$null) { $this->_data[$name] = $tmp[$name];
$value = gzuncompress($tmp[$name]);
if ($value === false)
throw new Doctrine_Record_Exception("Uncompressing of $name failed.");
$this->_data[$name] = $value;
}
break;
case "enum":
$this->_data[$name] = $this->_table->enumValue($name, $tmp[$name]);
break;
default:
$this->_data[$name] = $tmp[$name];
}; };
$count++; $count++;
} }
...@@ -421,38 +419,38 @@ abstract class Doctrine_Record extends Doctrine_Access implements Countable, Ite ...@@ -421,38 +419,38 @@ abstract class Doctrine_Record extends Doctrine_Access implements Countable, Ite
private function prepareIdentifiers($exists = true) private function prepareIdentifiers($exists = true)
{ {
switch ($this->_table->getIdentifierType()) { switch ($this->_table->getIdentifierType()) {
case Doctrine_Identifier::AUTO_INCREMENT: case Doctrine_Identifier::AUTO_INCREMENT:
case Doctrine_Identifier::SEQUENCE: case Doctrine_Identifier::SEQUENCE:
$name = $this->_table->getIdentifier(); $name = $this->_table->getIdentifier();
if ($exists) { if ($exists) {
if (isset($this->_data[$name]) && $this->_data[$name] !== self::$null) {
$this->_id[$name] = $this->_data[$name];
}
}
unset($this->_data[$name]);
break;
case Doctrine_Identifier::NORMAL:
$this->_id = array();
$name = $this->_table->getIdentifier();
if (isset($this->_data[$name]) && $this->_data[$name] !== self::$null) { if (isset($this->_data[$name]) && $this->_data[$name] !== self::$null) {
$this->_id[$name] = $this->_data[$name]; $this->_id[$name] = $this->_data[$name];
} }
} break;
case Doctrine_Identifier::COMPOSITE:
unset($this->_data[$name]); $names = $this->_table->getIdentifier();
break; foreach ($names as $name) {
case Doctrine_Identifier::NORMAL: if ($this->_data[$name] === self::$null) {
$this->_id = array(); $this->_id[$name] = null;
$name = $this->_table->getIdentifier(); } else {
$this->_id[$name] = $this->_data[$name];
if (isset($this->_data[$name]) && $this->_data[$name] !== self::$null) { }
$this->_id[$name] = $this->_data[$name];
}
break;
case Doctrine_Identifier::COMPOSITE:
$names = $this->_table->getIdentifier();
foreach ($names as $name) {
if ($this->_data[$name] === self::$null) {
$this->_id[$name] = null;
} else {
$this->_id[$name] = $this->_data[$name];
} }
} break;
break;
}; };
} }
/** /**
...@@ -475,16 +473,16 @@ abstract class Doctrine_Record extends Doctrine_Access implements Countable, Ite ...@@ -475,16 +473,16 @@ abstract class Doctrine_Record extends Doctrine_Access implements Countable, Ite
$this->_data = array_merge($this->_data, $this->_id); $this->_data = array_merge($this->_data, $this->_id);
foreach ($this->_data as $k => $v) { foreach ($this->_data as $k => $v) {
if ($v instanceof Doctrine_Record) if ($v instanceof Doctrine_Record) {
unset($vars['_data'][$k]); unset($vars['_data'][$k]);
elseif ($v === self::$null) { } elseif ($v === self::$null) {
unset($vars['_data'][$k]); unset($vars['_data'][$k]);
} else { } else {
switch ($this->_table->getTypeOf($k)) { switch ($this->_table->getTypeOf($k)) {
case "array": case "array":
case "object": case "object":
$vars['_data'][$k] = serialize($vars['_data'][$k]); $vars['_data'][$k] = serialize($vars['_data'][$k]);
break; break;
}; };
} }
} }
...@@ -560,16 +558,16 @@ abstract class Doctrine_Record extends Doctrine_Access implements Countable, Ite ...@@ -560,16 +558,16 @@ abstract class Doctrine_Record extends Doctrine_Access implements Countable, Ite
} elseif (is_string($state)) { } elseif (is_string($state)) {
$upper = strtoupper($state); $upper = strtoupper($state);
switch ($upper) { switch ($upper) {
case 'DIRTY': case 'DIRTY':
case 'CLEAN': case 'CLEAN':
case 'TDIRTY': case 'TDIRTY':
case 'TCLEAN': case 'TCLEAN':
case 'PROXY': case 'PROXY':
case 'DELETED': case 'DELETED':
$this->_state = constant('Doctrine_Record::STATE_' . $upper); $this->_state = constant('Doctrine_Record::STATE_' . $upper);
break; break;
default: default:
$err = true; $err = true;
} }
} }
...@@ -819,12 +817,12 @@ abstract class Doctrine_Record extends Doctrine_Access implements Countable, Ite ...@@ -819,12 +817,12 @@ abstract class Doctrine_Record extends Doctrine_Access implements Countable, Ite
$this->_data[$lower] = $value; $this->_data[$lower] = $value;
$this->_modified[] = $lower; $this->_modified[] = $lower;
switch ($this->_state) { switch ($this->_state) {
case Doctrine_Record::STATE_CLEAN: case Doctrine_Record::STATE_CLEAN:
$this->_state = Doctrine_Record::STATE_DIRTY; $this->_state = Doctrine_Record::STATE_DIRTY;
break; break;
case Doctrine_Record::STATE_TCLEAN: case Doctrine_Record::STATE_TCLEAN:
$this->_state = Doctrine_Record::STATE_TDIRTY; $this->_state = Doctrine_Record::STATE_TDIRTY;
break; break;
}; };
} }
} else { } else {
...@@ -1007,24 +1005,24 @@ abstract class Doctrine_Record extends Doctrine_Access implements Countable, Ite ...@@ -1007,24 +1005,24 @@ abstract class Doctrine_Record extends Doctrine_Access implements Countable, Ite
} }
switch ($type) { switch ($type) {
case 'array': case 'array':
case 'object': case 'object':
$a[$v] = serialize($this->_data[$v]); $a[$v] = serialize($this->_data[$v]);
break; break;
case 'gzip': case 'gzip':
$a[$v] = gzcompress($this->_data[$v],5); $a[$v] = gzcompress($this->_data[$v],5);
break; break;
case 'boolean': case 'boolean':
$a[$v] = (int) $this->_data[$v]; $a[$v] = (int) $this->_data[$v];
break;
case 'enum':
$a[$v] = $this->_table->enumIndex($v,$this->_data[$v]);
break; break;
default: case 'enum':
if ($this->_data[$v] instanceof Doctrine_Record) $a[$v] = $this->_table->enumIndex($v,$this->_data[$v]);
$this->_data[$v] = $this->_data[$v]->getIncremented(); break;
default:
$a[$v] = $this->_data[$v]; if ($this->_data[$v] instanceof Doctrine_Record)
$this->_data[$v] = $this->_data[$v]->getIncremented();
$a[$v] = $this->_data[$v];
} }
} }
......
...@@ -107,21 +107,21 @@ class Doctrine_Relation_Association extends Doctrine_Relation ...@@ -107,21 +107,21 @@ class Doctrine_Relation_Association extends Doctrine_Relation
public function getRelationDql($count, $context = 'record') public function getRelationDql($count, $context = 'record')
{ {
switch ($context) { switch ($context) {
case "record": case "record":
$sub = 'SQL:SELECT ' . $this->foreign. $sub = 'SQL:SELECT ' . $this->foreign.
' FROM ' . $this->associationTable->getTableName(). ' FROM ' . $this->associationTable->getTableName().
' WHERE ' . $this->local. ' WHERE ' . $this->local.
' IN (' . substr(str_repeat("?, ", $count),0,-2) . ' IN (' . substr(str_repeat("?, ", $count),0,-2) .
')'; ')';
$dql = "FROM ".$this->table->getComponentName(); $dql = "FROM ".$this->table->getComponentName();
$dql .= ".".$this->associationTable->getComponentName(); $dql .= ".".$this->associationTable->getComponentName();
$dql .= " WHERE ".$this->table->getComponentName().".".$this->table->getIdentifier()." IN ($sub)"; $dql .= " WHERE ".$this->table->getComponentName().".".$this->table->getIdentifier()." IN ($sub)";
break; break;
case "collection": case "collection":
$sub = substr(str_repeat("?, ", $count),0,-2); $sub = substr(str_repeat("?, ", $count),0,-2);
$dql = "FROM ".$this->associationTable->getComponentName().".".$this->table->getComponentName(); $dql = "FROM ".$this->associationTable->getComponentName().".".$this->table->getComponentName();
$dql .= " WHERE ".$this->associationTable->getComponentName().".".$this->local." IN ($sub)"; $dql .= " WHERE ".$this->associationTable->getComponentName().".".$this->local." IN ($sub)";
}; };
return $dql; return $dql;
......
...@@ -41,25 +41,25 @@ class Doctrine_Relation_Association_Self extends Doctrine_Relation_Association ...@@ -41,25 +41,25 @@ class Doctrine_Relation_Association_Self extends Doctrine_Relation_Association
public function getRelationDql($count, $context = 'record') public function getRelationDql($count, $context = 'record')
{ {
switch ($context) { switch ($context) {
case 'record': case 'record':
$sub = 'SELECT '.$this->foreign. $sub = 'SELECT '.$this->foreign.
' FROM '.$this->associationTable->getTableName(). ' FROM '.$this->associationTable->getTableName().
' WHERE '.$this->local. ' WHERE '.$this->local.
' = ?'; ' = ?';
$sub2 = 'SELECT '.$this->local. $sub2 = 'SELECT '.$this->local.
' FROM '.$this->associationTable->getTableName(). ' FROM '.$this->associationTable->getTableName().
' WHERE '.$this->foreign. ' WHERE '.$this->foreign.
' = ?'; ' = ?';
$dql = 'FROM '.$this->table->getComponentName(); $dql = 'FROM '.$this->table->getComponentName();
$dql .= '.'.$this->associationTable->getComponentName(); $dql .= '.'.$this->associationTable->getComponentName();
$dql .= ' WHERE '.$this->table->getComponentName().'.'.$this->table->getIdentifier().' IN ('.$sub.')'; $dql .= ' WHERE '.$this->table->getComponentName().'.'.$this->table->getIdentifier().' IN ('.$sub.')';
$dql .= ' || '.$this->table->getComponentName().'.'.$this->table->getIdentifier().' IN ('.$sub2.')'; $dql .= ' || '.$this->table->getComponentName().'.'.$this->table->getIdentifier().' IN ('.$sub2.')';
break; break;
case 'collection': case 'collection':
$sub = substr(str_repeat('?, ', $count),0,-2); $sub = substr(str_repeat('?, ', $count),0,-2);
$dql = 'FROM '.$this->associationTable->getComponentName().'.'.$this->table->getComponentName(); $dql = 'FROM '.$this->associationTable->getComponentName().'.'.$this->table->getComponentName();
$dql .= ' WHERE '.$this->associationTable->getComponentName().'.'.$this->local.' IN ('.$sub.')'; $dql .= ' WHERE '.$this->associationTable->getComponentName().'.'.$this->local.' IN ('.$sub.')';
}; };
return $dql; return $dql;
......
...@@ -187,55 +187,55 @@ class Doctrine_Table extends Doctrine_Configurable implements Countable ...@@ -187,55 +187,55 @@ class Doctrine_Table extends Doctrine_Configurable implements Countable
$this->options['tableName'] = Doctrine::tableize($class->getName()); $this->options['tableName'] = Doctrine::tableize($class->getName());
} }
switch (count($this->primaryKeys)) { switch (count($this->primaryKeys)) {
case 0: case 0:
$this->columns = array_merge(array('id' => $this->columns = array_merge(array('id' =>
array('integer', array('integer',
20, 20,
array('autoincrement' => true, array('autoincrement' => true,
'primary' => true 'primary' => true
) )
) )
), $this->columns); ), $this->columns);
$this->primaryKeys[] = 'id'; $this->primaryKeys[] = 'id';
$this->identifier = 'id'; $this->identifier = 'id';
$this->identifierType = Doctrine_Identifier::AUTO_INCREMENT; $this->identifierType = Doctrine_Identifier::AUTO_INCREMENT;
$this->columnCount++; $this->columnCount++;
break; break;
default: default:
if (count($this->primaryKeys) > 1) { if (count($this->primaryKeys) > 1) {
$this->identifier = $this->primaryKeys; $this->identifier = $this->primaryKeys;
$this->identifierType = Doctrine_Identifier::COMPOSITE; $this->identifierType = Doctrine_Identifier::COMPOSITE;
} else { } else {
foreach ($this->primaryKeys as $pk) { foreach ($this->primaryKeys as $pk) {
$e = $this->columns[$pk][2]; $e = $this->columns[$pk][2];
$found = false; $found = false;
foreach ($e as $option => $value) { foreach ($e as $option => $value) {
if ($found) if ($found)
break; break;
$e2 = explode(":",$option); $e2 = explode(":",$option);
switch (strtolower($e2[0])) { switch (strtolower($e2[0])) {
case "autoincrement": case "autoincrement":
$this->identifierType = Doctrine_Identifier::AUTO_INCREMENT; $this->identifierType = Doctrine_Identifier::AUTO_INCREMENT;
$found = true; $found = true;
break; break;
case "seq": case "seq":
$this->identifierType = Doctrine_Identifier::SEQUENCE; $this->identifierType = Doctrine_Identifier::SEQUENCE;
$found = true; $found = true;
break; break;
}; };
} }
if ( ! isset($this->identifierType)) { if ( ! isset($this->identifierType)) {
$this->identifierType = Doctrine_Identifier::NORMAL; $this->identifierType = Doctrine_Identifier::NORMAL;
}
$this->identifier = $pk;
} }
$this->identifier = $pk;
} }
}
}; };
if ($this->getAttribute(Doctrine::ATTR_CREATE_TABLES)) { if ($this->getAttribute(Doctrine::ATTR_CREATE_TABLES)) {
...@@ -306,15 +306,15 @@ class Doctrine_Table extends Doctrine_Configurable implements Countable ...@@ -306,15 +306,15 @@ class Doctrine_Table extends Doctrine_Configurable implements Countable
public function setOption($name, $value) public function setOption($name, $value)
{ {
switch ($name) { switch ($name) {
case 'name': case 'name':
case 'tableName': case 'tableName':
break; break;
case 'enumMap': case 'enumMap':
case 'inheritanceMap': case 'inheritanceMap':
if ( ! is_array($value)) { if ( ! is_array($value)) {
throw new Doctrine_Table_Exception($name.' should be an array.'); throw new Doctrine_Table_Exception($name.' should be an array.');
} }
break; break;
} }
$this->options[$name] = $value; $this->options[$name] = $value;
} }
...@@ -422,12 +422,12 @@ class Doctrine_Table extends Doctrine_Configurable implements Countable ...@@ -422,12 +422,12 @@ class Doctrine_Table extends Doctrine_Configurable implements Countable
final public function setPrimaryKey($key) final public function setPrimaryKey($key)
{ {
switch (gettype($key)) { switch (gettype($key)) {
case "array": case "array":
$this->primaryKeys = array_values($key); $this->primaryKeys = array_values($key);
break; break;
case "string": case "string":
$this->primaryKeys[] = $key; $this->primaryKeys[] = $key;
break; break;
}; };
} }
/** /**
...@@ -491,20 +491,20 @@ class Doctrine_Table extends Doctrine_Configurable implements Countable ...@@ -491,20 +491,20 @@ class Doctrine_Table extends Doctrine_Configurable implements Countable
$name = $this->getComponentName(); $name = $this->getComponentName();
foreach ($this->bound as $k=>$a) { foreach ($this->bound as $k=>$a) {
try { try {
$fk = $this->getRelation($k); $fk = $this->getRelation($k);
switch ($fk->getType()) { switch ($fk->getType()) {
case Doctrine_Relation::ONE_COMPOSITE: case Doctrine_Relation::ONE_COMPOSITE:
case Doctrine_Relation::MANY_COMPOSITE: case Doctrine_Relation::MANY_COMPOSITE:
$n = $fk->getTable()->getComponentName(); $n = $fk->getTable()->getComponentName();
$array[] = $name.".".$n; $array[] = $name.".".$n;
$e = $fk->getTable()->getCompositePaths(); $e = $fk->getTable()->getCompositePaths();
if ( ! empty($e)) { if ( ! empty($e)) {
foreach ($e as $name) { foreach ($e as $name) {
$array[] = $name.".".$n.".".$name; $array[] = $name.".".$n.".".$name;
} }
} }
break; break;
}; };
} catch(Doctrine_Table_Exception $e) { } catch(Doctrine_Table_Exception $e) {
} }
......
...@@ -71,14 +71,14 @@ class Doctrine_Transaction extends Doctrine_Connection_Module ...@@ -71,14 +71,14 @@ class Doctrine_Transaction extends Doctrine_Connection_Module
public function getState() public function getState()
{ {
switch ($this->transactionLevel) { switch ($this->transactionLevel) {
case 0: case 0:
return Doctrine_Transaction::STATE_SLEEP; return Doctrine_Transaction::STATE_SLEEP;
break; break;
case 1: case 1:
return Doctrine_Transaction::STATE_ACTIVE; return Doctrine_Transaction::STATE_ACTIVE;
break; break;
default: default:
return Doctrine_Transaction::STATE_BUSY; return Doctrine_Transaction::STATE_BUSY;
} }
} }
/** /**
......
...@@ -92,16 +92,16 @@ class Doctrine_Transaction_Firebird extends Doctrine_Transaction ...@@ -92,16 +92,16 @@ class Doctrine_Transaction_Firebird extends Doctrine_Transaction
switch ($isolation) { switch ($isolation) {
case 'READ UNCOMMITTED': case 'READ UNCOMMITTED':
$nativeIsolation = 'READ COMMITTED RECORD_VERSION'; $nativeIsolation = 'READ COMMITTED RECORD_VERSION';
break; break;
case 'READ COMMITTED': case 'READ COMMITTED':
$nativeIsolation = 'READ COMMITTED NO RECORD_VERSION'; $nativeIsolation = 'READ COMMITTED NO RECORD_VERSION';
break; break;
case 'REPEATABLE READ': case 'REPEATABLE READ':
$nativeIsolation = 'SNAPSHOT'; $nativeIsolation = 'SNAPSHOT';
break; break;
case 'SERIALIZABLE': case 'SERIALIZABLE':
$nativeIsolation = 'SNAPSHOT TABLE STABILITY'; $nativeIsolation = 'SNAPSHOT TABLE STABILITY';
break; break;
default: default:
throw new Doctrine_Transaction_Exception('isolation level is not supported: ' . $isolation); throw new Doctrine_Transaction_Exception('isolation level is not supported: ' . $isolation);
} }
...@@ -124,7 +124,7 @@ class Doctrine_Transaction_Firebird extends Doctrine_Transaction ...@@ -124,7 +124,7 @@ class Doctrine_Transaction_Firebird extends Doctrine_Transaction
case 'READ ONLY': case 'READ ONLY':
case 'READ WRITE': case 'READ WRITE':
$rw = ' ' . $options['rw']; $rw = ' ' . $options['rw'];
break; break;
default: default:
throw new Doctrine_Transaction_Exception('wait option is not supported: ' . $options['rw']); throw new Doctrine_Transaction_Exception('wait option is not supported: ' . $options['rw']);
} }
......
...@@ -56,8 +56,7 @@ class Doctrine_Transaction_Mssql extends Doctrine_Transaction ...@@ -56,8 +56,7 @@ class Doctrine_Transaction_Mssql extends Doctrine_Transaction
case 'REPEATABLE READ': case 'REPEATABLE READ':
case 'SERIALIZABLE': case 'SERIALIZABLE':
case 'SNAPSHOT': case 'SNAPSHOT':
break;
break;
default: default:
throw new Doctrine_Transaction_Exception('isolation level is not supported: ' . $isolation); throw new Doctrine_Transaction_Exception('isolation level is not supported: ' . $isolation);
} }
......
...@@ -91,8 +91,7 @@ class Doctrine_Transaction_Mysql extends Doctrine_Transaction ...@@ -91,8 +91,7 @@ class Doctrine_Transaction_Mysql extends Doctrine_Transaction
case 'READ COMMITTED': case 'READ COMMITTED':
case 'REPEATABLE READ': case 'REPEATABLE READ':
case 'SERIALIZABLE': case 'SERIALIZABLE':
break;
break;
default: default:
throw new Doctrine_Transaction_Exception('Isolation level ' . $isolation . ' is not supported.'); throw new Doctrine_Transaction_Exception('Isolation level ' . $isolation . ' is not supported.');
} }
......
...@@ -85,16 +85,16 @@ class Doctrine_Transaction_Oracle extends Doctrine_Transaction ...@@ -85,16 +85,16 @@ class Doctrine_Transaction_Oracle extends Doctrine_Transaction
public function setIsolation($isolation) public function setIsolation($isolation)
{ {
switch ($isolation) { switch ($isolation) {
case 'READ UNCOMMITTED': case 'READ UNCOMMITTED':
$isolation = 'READ COMMITTED'; $isolation = 'READ COMMITTED';
break; break;
case 'READ COMMITTED': case 'READ COMMITTED':
case 'REPEATABLE READ': case 'REPEATABLE READ':
case 'SERIALIZABLE': case 'SERIALIZABLE':
$isolation = 'SERIALIZABLE'; $isolation = 'SERIALIZABLE';
break; break;
default: default:
throw new Doctrine_Transaction_Exception('Isolation level ' . $isolation . ' is not supported.'); throw new Doctrine_Transaction_Exception('Isolation level ' . $isolation . ' is not supported.');
} }
$query = 'ALTER SESSION ISOLATION LEVEL ' . $isolation; $query = 'ALTER SESSION ISOLATION LEVEL ' . $isolation;
......
...@@ -91,8 +91,7 @@ class Doctrine_Transaction_Pgsql extends Doctrine_Transaction ...@@ -91,8 +91,7 @@ class Doctrine_Transaction_Pgsql extends Doctrine_Transaction
case 'READ COMMITTED': case 'READ COMMITTED':
case 'REPEATABLE READ': case 'REPEATABLE READ':
case 'SERIALIZABLE': case 'SERIALIZABLE':
break;
break;
default: default:
throw new Doctrine_Transaction_Exception('Isolation level '.$isolation.' is not supported.'); throw new Doctrine_Transaction_Exception('Isolation level '.$isolation.' is not supported.');
} }
......
...@@ -49,12 +49,12 @@ class Doctrine_Transaction_Sqlite extends Doctrine_Transaction ...@@ -49,12 +49,12 @@ class Doctrine_Transaction_Sqlite extends Doctrine_Transaction
switch ($isolation) { switch ($isolation) {
case 'READ UNCOMMITTED': case 'READ UNCOMMITTED':
$isolation = 0; $isolation = 0;
break; break;
case 'READ COMMITTED': case 'READ COMMITTED':
case 'REPEATABLE READ': case 'REPEATABLE READ':
case 'SERIALIZABLE': case 'SERIALIZABLE':
$isolation = 1; $isolation = 1;
break; break;
default: default:
throw new Doctrine_Transaction_Exception('Isolation level ' . $isolation . 'is not supported.'); throw new Doctrine_Transaction_Exception('Isolation level ' . $isolation . 'is not supported.');
} }
......
...@@ -211,18 +211,18 @@ class Doctrine_Validator ...@@ -211,18 +211,18 @@ class Doctrine_Validator
public static function phpType($doctrineType) public static function phpType($doctrineType)
{ {
switch ($doctrineType) { switch ($doctrineType) {
case 'enum': case 'enum':
return 'integer'; return 'integer';
case 'blob': case 'blob':
case 'clob': case 'clob':
case 'mbstring': case 'mbstring':
case 'timestamp': case 'timestamp':
case 'date': case 'date':
case 'gzip': case 'gzip':
return 'string'; return 'string';
break; break;
default: default:
return $doctrineType; return $doctrineType;
} }
} }
/** /**
...@@ -242,19 +242,19 @@ class Doctrine_Validator ...@@ -242,19 +242,19 @@ class Doctrine_Validator
$type = self::phpType($type); $type = self::phpType($type);
switch ($looseType) { switch ($looseType) {
case 'float': case 'float':
case 'double': case 'double':
case 'integer': case 'integer':
if ($type == 'string' || $type == 'float') if ($type == 'string' || $type == 'float')
return true;
case 'string':
case 'array':
case 'object':
return ($type === $looseType);
break;
case 'NULL':
return true; return true;
case 'string': break;
case 'array':
case 'object':
return ($type === $looseType);
break;
case 'NULL':
return true;
break;
}; };
} }
/** /**
...@@ -267,17 +267,17 @@ class Doctrine_Validator ...@@ -267,17 +267,17 @@ class Doctrine_Validator
{ {
$type = gettype($var); $type = gettype($var);
switch ($type) { switch ($type) {
case 'string': case 'string':
if (preg_match("/^[0-9]+$/",$var)) { if (preg_match("/^[0-9]+$/",$var)) {
return 'integer'; return 'integer';
} elseif (is_numeric($var)) { } elseif (is_numeric($var)) {
return 'float'; return 'float';
} else { } else {
return $type;
}
break;
default:
return $type; return $type;
}
break;
default:
return $type;
}; };
} }
} }
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