From 239995d3c379838eefed3d8699cca1502af7c9a2 Mon Sep 17 00:00:00 2001 From: lsmith Date: Fri, 29 Dec 2006 21:30:37 +0000 Subject: [PATCH] - fixed switch statement formating according to ZF CS --- lib/Doctrine/Collection.php | 54 ++-- lib/Doctrine/Collection/Batch.php | 14 +- lib/Doctrine/Configurable.php | 156 +++++------ lib/Doctrine/Connection.php | 66 ++--- lib/Doctrine/Connection/UnitOfWork.php | 22 +- lib/Doctrine/DataDict/Firebird.php | 72 +++--- lib/Doctrine/DataDict/Informix.php | 86 +++---- lib/Doctrine/DataDict/Mssql.php | 170 ++++++------ lib/Doctrine/DataDict/Mysql.php | 214 +++++++-------- lib/Doctrine/DataDict/Oracle.php | 180 ++++++------- lib/Doctrine/DataDict/Pgsql.php | 284 ++++++++++---------- lib/Doctrine/DataDict/Sqlite.php | 286 ++++++++++----------- lib/Doctrine/Db.php | 54 ++-- lib/Doctrine/Export/Firebird.php | 76 +++--- lib/Doctrine/Export/Mssql.php | 20 +- lib/Doctrine/Export/Mysql.php | 2 +- lib/Doctrine/Export/Oracle.php | 18 +- lib/Doctrine/Export/Pgsql.php | 2 +- lib/Doctrine/Export/Sqlite.php | 12 +- lib/Doctrine/Expression/Mssql.php | 10 +- lib/Doctrine/Expression/Mysql.php | 20 +- lib/Doctrine/Expression/Oracle.php | 10 +- lib/Doctrine/Expression/Pgsql.php | 22 +- lib/Doctrine/Expression/Sqlite.php | 14 +- lib/Doctrine/Hydrate.php | 34 +-- lib/Doctrine/Lib.php | 48 ++-- lib/Doctrine/Manager.php | 54 ++-- lib/Doctrine/Query/From.php | 8 +- lib/Doctrine/Query/Where.php | 72 +++--- lib/Doctrine/RawSql.php | 60 ++--- lib/Doctrine/Record.php | 192 +++++++------- lib/Doctrine/Relation/Association.php | 30 +-- lib/Doctrine/Relation/Association/Self.php | 38 +-- lib/Doctrine/Table.php | 152 +++++------ lib/Doctrine/Transaction.php | 16 +- lib/Doctrine/Transaction/Firebird.php | 10 +- lib/Doctrine/Transaction/Mssql.php | 3 +- lib/Doctrine/Transaction/Mysql.php | 3 +- lib/Doctrine/Transaction/Oracle.php | 20 +- lib/Doctrine/Transaction/Pgsql.php | 3 +- lib/Doctrine/Transaction/Sqlite.php | 4 +- lib/Doctrine/Validator.php | 68 ++--- 42 files changed, 1337 insertions(+), 1342 deletions(-) diff --git a/lib/Doctrine/Collection.php b/lib/Doctrine/Collection.php index 3c899fe6e..9b382187e 100644 --- a/lib/Doctrine/Collection.php +++ b/lib/Doctrine/Collection.php @@ -308,37 +308,37 @@ class Doctrine_Collection extends Doctrine_Access implements Countable, Iterator $offset = null; switch (get_class($this)) { - case "Doctrine_Collection_Offset": - $limit = $this->getLimit(); - $offset = (floor($key / $limit) * $limit); + case "Doctrine_Collection_Offset": + $limit = $this->getLimit(); + $offset = (floor($key / $limit) * $limit); - if ( ! $this->expandable && isset($this->expanded[$offset])) { - 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": + if ( ! $this->expandable && isset($this->expanded[$offset])) { + return false; + } $fields = implode(", ",$this->table->getColumnNames()); break; 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)) { diff --git a/lib/Doctrine/Collection/Batch.php b/lib/Doctrine/Collection/Batch.php index 81d993162..acedae59d 100644 --- a/lib/Doctrine/Collection/Batch.php +++ b/lib/Doctrine/Collection/Batch.php @@ -155,13 +155,13 @@ class Doctrine_Collection_Batch extends Doctrine_Collection { if (isset($this->data[$key])) { switch (gettype($this->data[$key])) { - case "array": - // Doctrine_Record didn't exist in cache - $this->table->setData($this->data[$key]); - $this->data[$key] = $this->table->getProxy(); - - $this->data[$key]->addCollection($this); - break; + case "array": + // Doctrine_Record didn't exist in cache + $this->table->setData($this->data[$key]); + $this->data[$key] = $this->table->getProxy(); + + $this->data[$key]->addCollection($this); + break; }; } else { $this->expand($key); diff --git a/lib/Doctrine/Configurable.php b/lib/Doctrine/Configurable.php index c4f784636..a3541a2a7 100644 --- a/lib/Doctrine/Configurable.php +++ b/lib/Doctrine/Configurable.php @@ -64,88 +64,88 @@ abstract class Doctrine_Configurable public function setAttribute($attribute,$value) { switch ($attribute) { - case Doctrine::ATTR_BATCH_SIZE: - if ($value < 0) { - 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."); + case Doctrine::ATTR_BATCH_SIZE: + if ($value < 0) { + throw new Doctrine_Exception("Batch size should be greater than or equal to zero"); } - } elseif ($this instanceof Doctrine_Manager) { - foreach ($this as $connection) { - if ($connection->transaction->getState() != Doctrine_Transaction::STATE_SLEEP) { + 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) { + 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 { - throw new Doctrine_Exception("Lockmode attribute can only be set at the global or connection level."); - } - break; - case Doctrine::ATTR_CREATE_TABLES: - $value = (bool) $value; - break; - case Doctrine::ATTR_ACCESSORS: - $accessors = array('none','get','set','both'); - - // if ( ! in_array($value,$accessors)) { - // throw new Doctrine_Exception(); - // } - - break; - case Doctrine::ATTR_COLL_LIMIT: - if ($value < 1) { - throw new Doctrine_Exception("Collection limit should be a value greater than or equal to 1."); - } - break; - case Doctrine::ATTR_COLL_KEY: - if ( ! ($this instanceof Doctrine_Table)) { - throw new Doctrine_Exception("This attribute can only be set at table level."); - } - if ( ! $this->hasColumn($value)) { - throw new Doctrine_Exception("Couldn't set collection key attribute. No such column '$value'"); - } - break; - case Doctrine::ATTR_VLD: - case Doctrine::ATTR_AUTO_LENGTH_VLD: - case Doctrine::ATTR_AUTO_TYPE_VLD: - case Doctrine::ATTR_QUERY_LIMIT: - case Doctrine::ATTR_QUOTE_IDENTIFIER: - case Doctrine::ATTR_PORTABILITY: - case Doctrine::ATTR_DEFAULT_TABLE_TYPE: - case Doctrine::ATTR_ACCESSOR_PREFIX_GET: - case Doctrine::ATTR_ACCESSOR_PREFIX_SET: - - break; - case Doctrine::ATTR_SEQCOL_NAME: - if ( ! is_string($value)) { - throw new Doctrine_Exception('Sequence column name attribute only accepts string values'); - } - break; - case Doctrine::ATTR_FIELD_CASE: - if ($value != 0 && $value != CASE_LOWER && $value != CASE_UPPER) - throw new Doctrine_Exception('Field case attribute should be either 0, CASE_LOWER or CASE_UPPER constant.'); - break; - case Doctrine::ATTR_SEQNAME_FORMAT: - case Doctrine::ATTR_IDXNAME_FORMAT: - if ($this instanceof Doctrine_Table) { - throw new Doctrine_Exception('Sequence / index name format attributes cannot be set' - . 'at table level (only at connection or global level).'); - } - break; - default: - throw new Doctrine_Exception("Unknown attribute."); + break; + case Doctrine::ATTR_CREATE_TABLES: + $value = (bool) $value; + break; + case Doctrine::ATTR_ACCESSORS: + $accessors = array('none','get','set','both'); + + // if ( ! in_array($value,$accessors)) { + // throw new Doctrine_Exception(); + // } + + break; + case Doctrine::ATTR_COLL_LIMIT: + if ($value < 1) { + throw new Doctrine_Exception("Collection limit should be a value greater than or equal to 1."); + } + break; + case Doctrine::ATTR_COLL_KEY: + if ( ! ($this instanceof Doctrine_Table)) { + throw new Doctrine_Exception("This attribute can only be set at table level."); + } + if ( ! $this->hasColumn($value)) { + throw new Doctrine_Exception("Couldn't set collection key attribute. No such column '$value'"); + } + break; + case Doctrine::ATTR_VLD: + case Doctrine::ATTR_AUTO_LENGTH_VLD: + case Doctrine::ATTR_AUTO_TYPE_VLD: + case Doctrine::ATTR_QUERY_LIMIT: + case Doctrine::ATTR_QUOTE_IDENTIFIER: + case Doctrine::ATTR_PORTABILITY: + case Doctrine::ATTR_DEFAULT_TABLE_TYPE: + case Doctrine::ATTR_ACCESSOR_PREFIX_GET: + case Doctrine::ATTR_ACCESSOR_PREFIX_SET: + + break; + case Doctrine::ATTR_SEQCOL_NAME: + if ( ! is_string($value)) { + throw new Doctrine_Exception('Sequence column name attribute only accepts string values'); + } + break; + case Doctrine::ATTR_FIELD_CASE: + if ($value != 0 && $value != CASE_LOWER && $value != CASE_UPPER) + throw new Doctrine_Exception('Field case attribute should be either 0, CASE_LOWER or CASE_UPPER constant.'); + break; + case Doctrine::ATTR_SEQNAME_FORMAT: + case Doctrine::ATTR_IDXNAME_FORMAT: + if ($this instanceof Doctrine_Table) { + throw new Doctrine_Exception('Sequence / index name format attributes cannot be set' + . 'at table level (only at connection or global level).'); + } + break; + default: + throw new Doctrine_Exception("Unknown attribute."); }; $this->attributes[$attribute] = $value; diff --git a/lib/Doctrine/Connection.php b/lib/Doctrine/Connection.php index a2d77f7df..044196868 100644 --- a/lib/Doctrine/Connection.php +++ b/lib/Doctrine/Connection.php @@ -160,13 +160,13 @@ abstract class Doctrine_Connection extends Doctrine_Configurable implements Coun } if ($this->modules[$name] === false) { switch ($name) { - case 'unitOfWork': - $this->modules[$name] = new Doctrine_Connection_UnitOfWork($this); - break; - default: - $class = 'Doctrine_' . ucwords($name) . '_' . $this->getName(); - $this->modules[$name] = new $class($this); - } + case 'unitOfWork': + $this->modules[$name] = new Doctrine_Connection_UnitOfWork($this); + break; + default: + $class = 'Doctrine_' . ucwords($name) . '_' . $this->getName(); + $this->modules[$name] = new $class($this); + } } return $this->modules[$name]; @@ -291,21 +291,21 @@ abstract class Doctrine_Connection extends Doctrine_Configurable implements Coun $type = gettype($input); } switch ($type) { - case 'integer': - case 'enum': - case 'boolean': - return $input; - case 'array': - case 'object': - $input = serialize($input); - case 'string': - case 'char': - case 'varchar': - case 'text': - case 'gzip': - case 'blob': - case 'clob': - return $this->dbh->quote($input); + case 'integer': + case 'enum': + case 'boolean': + return $input; + case 'array': + case 'object': + $input = serialize($input); + case 'string': + case 'char': + case 'varchar': + case 'text': + case 'gzip': + case 'blob': + case 'clob': + return $this->dbh->quote($input); } } /** @@ -874,17 +874,17 @@ abstract class Doctrine_Connection extends Doctrine_Configurable implements Coun $record->getTable()->getAttribute(Doctrine::ATTR_LISTENER)->onPreSave($record); switch ($record->getState()) { - case Doctrine_Record::STATE_TDIRTY: - $this->unitOfWork->insert($record); - break; - case Doctrine_Record::STATE_DIRTY: - case Doctrine_Record::STATE_PROXY: - $this->unitOfWork->update($record); - break; - case Doctrine_Record::STATE_CLEAN: - case Doctrine_Record::STATE_TCLEAN: - // do nothing - break; + case Doctrine_Record::STATE_TDIRTY: + $this->unitOfWork->insert($record); + break; + case Doctrine_Record::STATE_DIRTY: + case Doctrine_Record::STATE_PROXY: + $this->unitOfWork->update($record); + break; + case Doctrine_Record::STATE_CLEAN: + case Doctrine_Record::STATE_TCLEAN: + // do nothing + break; }; $record->getTable()->getAttribute(Doctrine::ATTR_LISTENER)->onSave($record); diff --git a/lib/Doctrine/Connection/UnitOfWork.php b/lib/Doctrine/Connection/UnitOfWork.php index dfb90ee5e..8fd580ada 100644 --- a/lib/Doctrine/Connection/UnitOfWork.php +++ b/lib/Doctrine/Connection/UnitOfWork.php @@ -204,11 +204,11 @@ class Doctrine_Connection_UnitOfWork extends Doctrine_Connection_Module implemen { foreach ($record->getTable()->getRelations() as $fk) { switch ($fk->getType()) { - case Doctrine_Relation::ONE_COMPOSITE: - case Doctrine_Relation::MANY_COMPOSITE: - $obj = $record->get($fk->getAlias()); - $obj->delete(); - break; + case Doctrine_Relation::ONE_COMPOSITE: + case Doctrine_Relation::MANY_COMPOSITE: + $obj = $record->get($fk->getAlias()); + $obj->delete(); + break; }; } } @@ -263,12 +263,12 @@ class Doctrine_Connection_UnitOfWork extends Doctrine_Connection_Module implemen if ($value instanceof Doctrine_Record) { switch ($value->getState()) { - case Doctrine_Record::STATE_TCLEAN: - case Doctrine_Record::STATE_TDIRTY: - $record->save(); - default: - $array[$name] = $value->getIncremented(); - $record->set($name, $value->getIncremented()); + case Doctrine_Record::STATE_TCLEAN: + case Doctrine_Record::STATE_TDIRTY: + $record->save(); + default: + $array[$name] = $value->getIncremented(); + $record->set($name, $value->getIncremented()); }; } }; diff --git a/lib/Doctrine/DataDict/Firebird.php b/lib/Doctrine/DataDict/Firebird.php index a08ef4b2d..dbdd8a6d0 100644 --- a/lib/Doctrine/DataDict/Firebird.php +++ b/lib/Doctrine/DataDict/Firebird.php @@ -57,38 +57,38 @@ class Doctrine_DataDict_Firebird extends Doctrine_DataDict public function getNativeDeclaration($field) { switch ($field['type']) { - case 'varchar': - case 'string': - case 'array': - case 'object': - case 'char': - case 'text': - $length = !empty($field['length']) - ? $field['length'] : 16777215; // TODO: $db->options['default_text_field_length']; - - $fixed = ((isset($field['fixed']) && $field['fixed']) || $field['type'] == 'char') ? true : false; - - return $fixed ? 'CHAR('.$length.')' : 'VARCHAR('.$length.')'; - case 'clob': - return 'BLOB SUB_TYPE 1'; - case 'blob': - return 'BLOB SUB_TYPE 0'; - case 'integer': - case 'enum': - return 'INT'; - case 'boolean': - return 'SMALLINT'; - case 'date': - return 'DATE'; - case 'time': - return 'TIME'; - case 'timestamp': - return 'TIMESTAMP'; - case 'float': - return 'DOUBLE PRECISION'; - case 'decimal': - $length = !empty($field['length']) ? $field['length'] : 18; - return 'DECIMAL('.$length.','.$db->options['decimal_places'].')'; + case 'varchar': + case 'string': + case 'array': + case 'object': + case 'char': + case 'text': + $length = !empty($field['length']) + ? $field['length'] : 16777215; // TODO: $db->options['default_text_field_length']; + + $fixed = ((isset($field['fixed']) && $field['fixed']) || $field['type'] == 'char') ? true : false; + + return $fixed ? 'CHAR('.$length.')' : 'VARCHAR('.$length.')'; + case 'clob': + return 'BLOB SUB_TYPE 1'; + case 'blob': + return 'BLOB SUB_TYPE 0'; + case 'integer': + case 'enum': + return 'INT'; + case 'boolean': + return 'SMALLINT'; + case 'date': + return 'DATE'; + case 'time': + return 'TIME'; + case 'timestamp': + return 'TIMESTAMP'; + case 'float': + return 'DOUBLE PRECISION'; + case 'decimal': + $length = !empty($field['length']) ? $field['length'] : 18; + return 'DECIMAL('.$length.','.$db->options['decimal_places'].')'; } return ''; } @@ -129,7 +129,7 @@ class Doctrine_DataDict_Firebird extends Doctrine_DataDict $type = array_reverse($type); } } - break; + break; case 'varchar': $fixed = false; case 'char': @@ -144,15 +144,15 @@ class Doctrine_DataDict_Firebird extends Doctrine_DataDict if ($fixed !== false) { $fixed = true; } - break; + break; case 'date': $type[] = 'date'; $length = null; - break; + break; case 'timestamp': $type[] = 'timestamp'; $length = null; - break; + break; case 'time': $type[] = 'time'; $length = null; diff --git a/lib/Doctrine/DataDict/Informix.php b/lib/Doctrine/DataDict/Informix.php index d06bc4d5e..ce6bb0bbc 100644 --- a/lib/Doctrine/DataDict/Informix.php +++ b/lib/Doctrine/DataDict/Informix.php @@ -57,50 +57,50 @@ class Doctrine_DataDict_Informix extends Doctrine_DataDict public function getNativeDeclaration($field) { switch ($field['type']) { - case 'char': - case 'varchar': - case 'array': - case 'object': - case 'string': - if (empty($field['length']) && array_key_exists('default', $field)) { - $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)'; + case 'char': + case 'varchar': + case 'array': + case 'object': + case 'string': + if (empty($field['length']) && array_key_exists('default', $field)) { + $field['length'] = $this->conn->varchar_max_length; } - } - 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'; + + $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'; + 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 ''; } diff --git a/lib/Doctrine/DataDict/Mssql.php b/lib/Doctrine/DataDict/Mssql.php index 62323e18b..7f8e6fa5e 100644 --- a/lib/Doctrine/DataDict/Mssql.php +++ b/lib/Doctrine/DataDict/Mssql.php @@ -59,51 +59,51 @@ class Doctrine_DataDict_Mssql extends Doctrine_DataDict public function getNativeDeclaration($field) { switch ($field['type']) { - case 'array': - case 'object': - case 'text': - case 'char': - case 'varchar': - case 'string': - $length = !empty($field['length']) - ? $field['length'] : false; - - $fixed = ((isset($field['fixed']) && $field['fixed']) || $field['type'] == 'char') ? true : false; - - return $fixed ? ($length ? 'CHAR('.$length.')' : 'CHAR('.$db->options['default_text_field_length'].')') - : ($length ? 'VARCHAR('.$length.')' : 'TEXT'); - case 'clob': - if (!empty($field['length'])) { - $length = $field['length']; - if ($length <= 8000) { - return 'VARCHAR('.$length.')'; + case 'array': + case 'object': + case 'text': + case 'char': + case 'varchar': + case 'string': + $length = !empty($field['length']) + ? $field['length'] : false; + + $fixed = ((isset($field['fixed']) && $field['fixed']) || $field['type'] == 'char') ? true : false; + + return $fixed ? ($length ? 'CHAR('.$length.')' : 'CHAR('.$db->options['default_text_field_length'].')') + : ($length ? 'VARCHAR('.$length.')' : 'TEXT'); + case 'clob': + if (!empty($field['length'])) { + $length = $field['length']; + if ($length <= 8000) { + return 'VARCHAR('.$length.')'; + } + } + return 'TEXT'; + case 'blob': + if (!empty($field['length'])) { + $length = $field['length']; + if ($length <= 8000) { + return "VARBINARY($length)"; + } } - } - return 'TEXT'; - case 'blob': - if (!empty($field['length'])) { - $length = $field['length']; - if ($length <= 8000) { - return "VARBINARY($length)"; - } - } - return 'IMAGE'; - case 'integer': - case 'enum': - return 'INT'; - case 'boolean': - return 'BIT'; - case 'date': - return 'CHAR(' . strlen('YYYY-MM-DD') . ')'; - case 'time': - return 'CHAR(' . strlen('HH:MM:SS') . ')'; - case 'timestamp': - return 'CHAR(' . strlen('YYYY-MM-DD HH:MM:SS') . ')'; - case 'float': - return 'FLOAT'; - case 'decimal': - $length = !empty($field['length']) ? $field['length'] : 18; - return 'DECIMAL('.$length.','.$db->options['decimal_places'].')'; + return 'IMAGE'; + case 'integer': + case 'enum': + return 'INT'; + case 'boolean': + return 'BIT'; + case 'date': + return 'CHAR(' . strlen('YYYY-MM-DD') . ')'; + case 'time': + return 'CHAR(' . strlen('HH:MM:SS') . ')'; + case 'timestamp': + return 'CHAR(' . strlen('YYYY-MM-DD HH:MM:SS') . ')'; + case 'float': + return 'FLOAT'; + case 'decimal': + $length = !empty($field['length']) ? $field['length'] : 18; + return 'DECIMAL('.$length.','.$db->options['decimal_places'].')'; } return ''; } @@ -124,48 +124,48 @@ class Doctrine_DataDict_Mssql extends Doctrine_DataDict // todo: unsigned handling seems to be missing $unsigned = $fixed = null; switch ($db_type) { - case 'bit': - $type[0] = 'boolean'; - break; - case 'int': - $type[0] = 'integer'; - break; - case 'datetime': - $type[0] = 'timestamp'; - break; - case 'float': - case 'real': - case 'numeric': - $type[0] = 'float'; - break; - case 'decimal': - case 'money': - $type[0] = 'decimal'; - break; - case 'text': - case 'varchar': - $fixed = false; - case 'char': - $type[0] = 'text'; - if ($length == '1') { - $type[] = 'boolean'; - if (preg_match('/^[is|has]/', $field['name'])) { - $type = array_reverse($type); + case 'bit': + $type[0] = 'boolean'; + break; + case 'int': + $type[0] = 'integer'; + break; + case 'datetime': + $type[0] = 'timestamp'; + break; + case 'float': + case 'real': + case 'numeric': + $type[0] = 'float'; + break; + case 'decimal': + case 'money': + $type[0] = 'decimal'; + break; + case 'text': + case 'varchar': + $fixed = false; + case 'char': + $type[0] = 'text'; + if ($length == '1') { + $type[] = 'boolean'; + if (preg_match('/^[is|has]/', $field['name'])) { + $type = array_reverse($type); + } + } elseif (strstr($db_type, 'text')) { + $type[] = 'clob'; } - } elseif (strstr($db_type, 'text')) { - $type[] = 'clob'; - } - if ($fixed !== false) { - $fixed = true; - } - break; - case 'image': - case 'varbinary': - $type[] = 'blob'; - $length = null; - break; - default: - throw new Doctrine_DataDict_Mssql_Exception('unknown database attribute type: '.$db_type); + if ($fixed !== false) { + $fixed = true; + } + break; + case 'image': + case 'varbinary': + $type[] = 'blob'; + $length = null; + break; + default: + throw new Doctrine_DataDict_Mssql_Exception('unknown database attribute type: '.$db_type); } return array($type, $length, $unsigned, $fixed); diff --git a/lib/Doctrine/DataDict/Mysql.php b/lib/Doctrine/DataDict/Mysql.php index 1b226a565..91c22e035 100644 --- a/lib/Doctrine/DataDict/Mysql.php +++ b/lib/Doctrine/DataDict/Mysql.php @@ -236,122 +236,122 @@ class Doctrine_DataDict_Mysql extends Doctrine_DataDict $type = array(); $unsigned = $fixed = null; switch ($dbType) { - case 'tinyint': - $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') { + case 'tinyint': + $type[] = 'integer'; $type[] = 'boolean'; if (preg_match('/^(is|has)/', $field['name'])) { $type = array_reverse($type); } - } elseif (strstr($dbType, 'text')) { - $type[] = 'clob'; - if ($decimal == 'binary') { - $type[] = 'blob'; - } - } - if ($fixed !== false) { - $fixed = true; - } - break; - case 'enum': - $type[] = 'text'; - preg_match_all('/\'.+\'/U', $field['type'], $matches); - $length = 0; - $fixed = false; - if (is_array($matches)) { - foreach ($matches[0] as $value) { - $length = max($length, strlen($value)-2); - } - if ($length == '1' && count($matches[0]) == 2) { + $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'; if (preg_match('/^(is|has)/', $field['name'])) { $type = array_reverse($type); } + } elseif (strstr($dbType, 'text')) { + $type[] = 'clob'; + if ($decimal == 'binary') { + $type[] = 'blob'; + } } - } - $type[] = 'integer'; - case 'set': - $fixed = false; - $type[] = 'text'; - $type[] = 'integer'; - 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'; - $unsigned = preg_match('/ unsigned/i', $field['type']); - break; - 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); + if ($fixed !== false) { + $fixed = true; + } + break; + case 'enum': + $type[] = 'text'; + preg_match_all('/\'.+\'/U', $field['type'], $matches); + $length = 0; + $fixed = false; + if (is_array($matches)) { + foreach ($matches[0] as $value) { + $length = max($length, strlen($value)-2); + } + if ($length == '1' && count($matches[0]) == 2) { + $type[] = 'boolean'; + if (preg_match('/^(is|has)/', $field['name'])) { + $type = array_reverse($type); + } + } + } + $type[] = 'integer'; + case 'set': + $fixed = false; + $type[] = 'text'; + $type[] = 'integer'; + 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'; + $unsigned = preg_match('/ unsigned/i', $field['type']); + break; + 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); diff --git a/lib/Doctrine/DataDict/Oracle.php b/lib/Doctrine/DataDict/Oracle.php index 408827083..ba6bc5d35 100644 --- a/lib/Doctrine/DataDict/Oracle.php +++ b/lib/Doctrine/DataDict/Oracle.php @@ -54,38 +54,38 @@ class Doctrine_DataDict_Oracle extends Doctrine_DataDict public function getNativeDeclaration(array $field) { switch ($field['type']) { - case 'string': - case 'array': - case 'object': - case 'gzip': - case 'char': - case 'varchar': - $length = !empty($field['length']) - ? $field['length'] : 16777215; // TODO: $db->options['default_text_field_length']; - - $fixed = ((isset($field['fixed']) && $field['fixed']) || $field['type'] == 'char') ? true : false; - - return $fixed ? 'CHAR('.$length.')' : 'VARCHAR2('.$length.')'; - case 'clob': - return 'CLOB'; - case 'blob': - return 'BLOB'; - case 'integer': - case 'enum': - if (!empty($field['length'])) { - return 'NUMBER('.$field['length'].')'; - } - return 'INT'; - case 'boolean': - return 'NUMBER(1)'; - case 'date': - case 'time': - case 'timestamp': - return 'DATE'; - case 'float': - return 'NUMBER'; - case 'decimal': - return 'NUMBER(*,'.$db->options['decimal_places'].')'; + case 'string': + case 'array': + case 'object': + case 'gzip': + case 'char': + case 'varchar': + $length = !empty($field['length']) + ? $field['length'] : 16777215; // TODO: $db->options['default_text_field_length']; + + $fixed = ((isset($field['fixed']) && $field['fixed']) || $field['type'] == 'char') ? true : false; + + return $fixed ? 'CHAR('.$length.')' : 'VARCHAR2('.$length.')'; + case 'clob': + return 'CLOB'; + case 'blob': + return 'BLOB'; + case 'integer': + case 'enum': + if (!empty($field['length'])) { + return 'NUMBER('.$field['length'].')'; + } + return 'INT'; + case 'boolean': + return 'NUMBER(1)'; + case 'date': + case 'time': + case 'timestamp': + return 'DATE'; + case 'float': + return 'NUMBER'; + case 'decimal': + return 'NUMBER(*,'.$db->options['decimal_places'].')'; } } /** @@ -104,46 +104,9 @@ class Doctrine_DataDict_Oracle extends Doctrine_DataDict $length = $field['length']; } switch ($db_type) { - case 'integer': - case 'pls_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 { + case 'integer': + case 'pls_integer': + case 'binary_integer': $type[] = 'integer'; if ($length == '1') { $type[] = 'boolean'; @@ -151,25 +114,62 @@ class Doctrine_DataDict_Oracle extends Doctrine_DataDict $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'; + 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; - 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; - case 'rowid': - case 'urowid': - default: - throw new Doctrine_DataDict_Oracle_Exception('unknown database attribute type: '.$db_type); + case 'rowid': + case 'urowid': + default: + throw new Doctrine_DataDict_Oracle_Exception('unknown database attribute type: '.$db_type); } return array($type, $length, $unsigned, $fixed); diff --git a/lib/Doctrine/DataDict/Pgsql.php b/lib/Doctrine/DataDict/Pgsql.php index 511e7652d..848c80d06 100644 --- a/lib/Doctrine/DataDict/Pgsql.php +++ b/lib/Doctrine/DataDict/Pgsql.php @@ -359,60 +359,60 @@ class Doctrine_DataDict_Pgsql extends Doctrine_DataDict public function getNativeDeclaration(array $field) { switch ($field['type']) { - case 'char': - case 'string': - case 'array': - case 'object': - case 'varchar': - $length = (isset($field['length']) && $field['length']) ? $field['length'] : null; - // TODO: $db->options['default_text_field_length']; - - $fixed = ((isset($field['fixed']) && $field['fixed']) || $field['type'] == 'char') ? true : false; - - return $fixed ? ($length ? 'CHAR('.$length.')' : 'CHAR('.$db->options['default_text_field_length'].')') - : ($length ? 'VARCHAR('.$length.')' : 'TEXT'); - - case 'clob': - return 'TEXT'; - case 'blob': - return 'BYTEA'; - case 'enum': - case 'integer': - if (!empty($field['autoincrement'])) { + case 'char': + case 'string': + case 'array': + case 'object': + case 'varchar': + $length = (isset($field['length']) && $field['length']) ? $field['length'] : null; + // TODO: $db->options['default_text_field_length']; + + $fixed = ((isset($field['fixed']) && $field['fixed']) || $field['type'] == 'char') ? true : false; + + return $fixed ? ($length ? 'CHAR('.$length.')' : 'CHAR('.$db->options['default_text_field_length'].')') + : ($length ? 'VARCHAR('.$length.')' : 'TEXT'); + + case 'clob': + return 'TEXT'; + case 'blob': + return 'BYTEA'; + case 'enum': + case 'integer': + 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'])) { $length = $field['length']; - if ($length > 4) { - return 'BIGSERIAL PRIMARY KEY'; + if ($length <= 2) { + return 'SMALLINT'; + } elseif ($length == 3 || $length == 4) { + return 'INT'; + } elseif ($length > 4) { + return 'BIGINT'; } } - return 'SERIAL PRIMARY KEY'; - } - if (!empty($field['length'])) { - $length = $field['length']; - if ($length <= 2) { - return 'SMALLINT'; - } elseif ($length == 3 || $length == 4) { - return 'INT'; - } elseif ($length > 4) { - return 'BIGINT'; - } - } - return 'INT'; - case 'boolean': - return 'BOOLEAN'; - case 'date': - 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']); + return 'INT'; + case 'boolean': + return 'BOOLEAN'; + case 'date': + 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 $type = array(); $unsigned = $fixed = null; switch (strtolower($field['type'])) { - case 'smallint': - case 'int2': - $type[] = 'integer'; - $unsigned = false; - $length = 2; - if ($length == '2') { - $type[] = 'boolean'; - if (preg_match('/^(is|has)/', $field['name'])) { - $type = array_reverse($type); + case 'smallint': + case 'int2': + $type[] = 'integer'; + $unsigned = false; + $length = 2; + if ($length == '2') { + $type[] = 'boolean'; + if (preg_match('/^(is|has)/', $field['name'])) { + $type = array_reverse($type); + } } - } - break; - case 'int': - case 'int4': - case 'integer': - case 'serial': - case 'serial4': - $type[] = 'integer'; - $unsigned = false; - $length = 4; - break; - case 'bigint': - case 'int8': - case 'bigserial': - case 'serial8': - $type[] = 'integer'; - $unsigned = false; - $length = 8; - break; - case 'bool': - case 'boolean': - $type[] = 'boolean'; - $length = 1; - break; - case 'text': - case 'varchar': - $fixed = false; - case 'unknown': - case 'char': - case 'bpchar': - $type[] = 'text'; - if ($length == '1') { + break; + case 'int': + case 'int4': + case 'integer': + case 'serial': + case 'serial4': + $type[] = 'integer'; + $unsigned = false; + $length = 4; + break; + case 'bigint': + case 'int8': + case 'bigserial': + case 'serial8': + $type[] = 'integer'; + $unsigned = false; + $length = 8; + break; + case 'bool': + case 'boolean': $type[] = 'boolean'; - if (preg_match('/^(is|has)/', $field['name'])) { - $type = array_reverse($type); + $length = 1; + 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'; } - } elseif (strstr($db_type, 'text')) { + 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'; + 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'; - } - 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'; - 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); + $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); diff --git a/lib/Doctrine/DataDict/Sqlite.php b/lib/Doctrine/DataDict/Sqlite.php index 38a9bf355..ae446fe33 100644 --- a/lib/Doctrine/DataDict/Sqlite.php +++ b/lib/Doctrine/DataDict/Sqlite.php @@ -57,60 +57,60 @@ class Doctrine_DataDict_Sqlite extends Doctrine_DataDict public function getNativeDeclaration(array $field) { switch ($field['type']) { - case 'text': - case 'object': - case 'array': - case 'string': - case 'char': - case 'gzip': - case 'varchar': - $length = (isset($field['length']) && $field['length']) ? $field['length'] : null; - - $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).')') - : ($length ? 'VARCHAR('.$length.')' : 'TEXT'); - case 'clob': - if (!empty($field['length'])) { - $length = $field['length']; - if ($length <= 255) { - return 'TINYTEXT'; - } elseif ($length <= 65535) { - return 'TEXT'; - } elseif ($length <= 16777215) { - return 'MEDIUMTEXT'; + case 'text': + case 'object': + case 'array': + case 'string': + case 'char': + case 'gzip': + case 'varchar': + $length = (isset($field['length']) && $field['length']) ? $field['length'] : null; + + $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).')') + : ($length ? 'VARCHAR('.$length.')' : 'TEXT'); + case 'clob': + if (!empty($field['length'])) { + $length = $field['length']; + if ($length <= 255) { + return 'TINYTEXT'; + } elseif ($length <= 65535) { + return 'TEXT'; + } elseif ($length <= 16777215) { + return 'MEDIUMTEXT'; + } } - } - return 'LONGTEXT'; - case 'blob': - if (!empty($field['length'])) { - $length = $field['length']; - if ($length <= 255) { - return 'TINYBLOB'; - } elseif ($length <= 65535) { - return 'BLOB'; - } elseif ($length <= 16777215) { - return 'MEDIUMBLOB'; + return 'LONGTEXT'; + case 'blob': + if (!empty($field['length'])) { + $length = $field['length']; + if ($length <= 255) { + return 'TINYBLOB'; + } elseif ($length <= 65535) { + return 'BLOB'; + } elseif ($length <= 16777215) { + return 'MEDIUMBLOB'; + } } - } - return 'LONGBLOB'; - case 'enum': - case 'integer': - case 'boolean': - return 'INTEGER'; - case 'date': - return 'DATE'; - case 'time': - return 'TIME'; - case 'timestamp': - return 'DATETIME'; - case 'float': - case 'double': - return 'DOUBLE';//($db->options['fixed_float'] ? '('. - //($db->options['fixed_float']+2).','.$db->options['fixed_float'].')' : ''); - case 'decimal': - $length = !empty($field['length']) ? $field['length'] : 18; - return 'DECIMAL('.$length.','.$db->options['decimal_places'].')'; + return 'LONGBLOB'; + case 'enum': + case 'integer': + case 'boolean': + return 'INTEGER'; + case 'date': + return 'DATE'; + case 'time': + return 'TIME'; + case 'timestamp': + return 'DATETIME'; + case 'float': + case 'double': + return 'DOUBLE';//($db->options['fixed_float'] ? '('. + //($db->options['fixed_float']+2).','.$db->options['fixed_float'].')' : ''); + case 'decimal': + $length = !empty($field['length']) ? $field['length'] : 18; + return 'DECIMAL('.$length.','.$db->options['decimal_places'].')'; } throw new Doctrine_DataDict_Sqlite_Exception('Unknown datatype ' . $field['type']); } @@ -128,101 +128,101 @@ class Doctrine_DataDict_Sqlite extends Doctrine_DataDict $fixed = null; $type = array(); switch ($dbType) { - case 'boolean': - $type[] = 'boolean'; - break; - case 'tinyint': - $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') { + case 'boolean': + $type[] = 'boolean'; + break; + case 'tinyint': + $type[] = 'integer'; $type[] = 'boolean'; if (preg_match('/^(is|has)/', $field['name'])) { $type = array_reverse($type); } - } elseif (strstr($dbType, 'text')) { - $type[] = 'clob'; - } - 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); + $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'; + if (preg_match('/^(is|has)/', $field['name'])) { + $type = array_reverse($type); + } + } elseif (strstr($dbType, 'text')) { + $type[] = 'clob'; + } + 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); diff --git a/lib/Doctrine/Db.php b/lib/Doctrine/Db.php index e0a2f832a..adb01f602 100644 --- a/lib/Doctrine/Db.php +++ b/lib/Doctrine/Db.php @@ -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'); } switch ($parts['scheme']) { - case 'sqlite': - if (isset($parts['host']) && $parts['host'] == ':memory') { - $parts['database'] = ':memory:'; - $parts['dsn'] = 'sqlite::memory:'; - } - - break; - case 'mysql': - case 'informix': - case 'oci8': - case 'mssql': - case 'firebird': - case 'pgsql': - case 'odbc': - if ( ! isset($parts['path']) || $parts['path'] == '/') { - throw new Doctrine_Db_Exception('No database availible in data source name'); - } - if (isset($parts['path'])) { - $parts['database'] = substr($parts['path'], 1); - } - if ( ! isset($parts['host'])) { - throw new Doctrine_Db_Exception('No hostname set in data source name'); - } - $parts['dsn'] = $parts["scheme"].":host=".$parts["host"].";dbname=".$parts["database"]; - break; - default: - throw new Doctrine_Db_Exception('Unknown driver '.$parts['scheme']); + case 'sqlite': + if (isset($parts['host']) && $parts['host'] == ':memory') { + $parts['database'] = ':memory:'; + $parts['dsn'] = 'sqlite::memory:'; + } + + break; + case 'mysql': + case 'informix': + case 'oci8': + case 'mssql': + case 'firebird': + case 'pgsql': + case 'odbc': + if ( ! isset($parts['path']) || $parts['path'] == '/') { + throw new Doctrine_Db_Exception('No database availible in data source name'); + } + if (isset($parts['path'])) { + $parts['database'] = substr($parts['path'], 1); + } + if ( ! isset($parts['host'])) { + throw new Doctrine_Db_Exception('No hostname set in data source name'); + } + $parts['dsn'] = $parts["scheme"].":host=".$parts["host"].";dbname=".$parts["database"]; + break; + default: + throw new Doctrine_Db_Exception('Unknown driver '.$parts['scheme']); } return $parts; diff --git a/lib/Doctrine/Export/Firebird.php b/lib/Doctrine/Export/Firebird.php index 040f913c5..72f381d48 100644 --- a/lib/Doctrine/Export/Firebird.php +++ b/lib/Doctrine/Export/Firebird.php @@ -189,25 +189,25 @@ class Doctrine_Export_Firebird extends Doctrine_Export { foreach ($changes as $change_name => $change) { switch ($change_name) { - case 'notnull': - return $db->raiseError(MDB2_ERROR_UNSUPPORTED, null, null, - 'it is not supported changes to field not null constraint', __FUNCTION__); - case 'default': - return $db->raiseError(MDB2_ERROR_UNSUPPORTED, null, null, - 'it is not supported changes to field default value', __FUNCTION__); - case 'length': - /* - return $db->raiseError(MDB2_ERROR_UNSUPPORTED, null, null, - 'it is not supported changes to field default length', __FUNCTION__); - */ - case 'unsigned': - case 'type': - case 'declaration': - case 'definition': - break; - default: - return $db->raiseError(MDB2_ERROR_UNSUPPORTED, null, null, - 'it is not supported change of type' . $change_name, __FUNCTION__); + case 'notnull': + return $db->raiseError(MDB2_ERROR_UNSUPPORTED, null, null, + 'it is not supported changes to field not null constraint', __FUNCTION__); + case 'default': + return $db->raiseError(MDB2_ERROR_UNSUPPORTED, null, null, + 'it is not supported changes to field default value', __FUNCTION__); + case 'length': + /* + return $db->raiseError(MDB2_ERROR_UNSUPPORTED, null, null, + 'it is not supported changes to field default length', __FUNCTION__); + */ + case 'unsigned': + case 'type': + case 'declaration': + case 'definition': + break; + default: + return $db->raiseError(MDB2_ERROR_UNSUPPORTED, null, null, + 'it is not supported change of type' . $change_name, __FUNCTION__); } } return MDB2_OK; @@ -320,20 +320,20 @@ class Doctrine_Export_Firebird extends Doctrine_Export { foreach ($changes as $change_name => $change) { switch ($change_name) { - case 'add': - case 'remove': - case 'rename': - break; - case 'change': - foreach ($changes['change'] as $field) { - if (PEAR::isError($err = $this->checkSupportedChanges($field))) { - return $err; + case 'add': + case 'remove': + case 'rename': + break; + case 'change': + foreach ($changes['change'] as $field) { + if (PEAR::isError($err = $this->checkSupportedChanges($field))) { + return $err; + } } - } - break; - default: - return $db->raiseError(MDB2_ERROR_CANNOT_ALTER, null, null, - 'change type ' . $change_name . ' not yet supported', __FUNCTION__); + break; + default: + return $db->raiseError(MDB2_ERROR_CANNOT_ALTER, null, null, + 'change type ' . $change_name . ' not yet supported', __FUNCTION__); } } if ($check) { @@ -432,12 +432,12 @@ class Doctrine_Export_Firebird extends Doctrine_Export foreach ($definition['fields'] as $field) { if (!strcmp($query_sort, '') && isset($field['sorting'])) { switch ($field['sorting']) { - case 'ascending': - $query_sort = ' ASC'; - break; - case 'descending': - $query_sort = ' DESC'; - break; + case 'ascending': + $query_sort = ' ASC'; + break; + case 'descending': + $query_sort = ' DESC'; + break; } } } diff --git a/lib/Doctrine/Export/Mssql.php b/lib/Doctrine/Export/Mssql.php index c965d780c..b5765c1c2 100644 --- a/lib/Doctrine/Export/Mssql.php +++ b/lib/Doctrine/Export/Mssql.php @@ -154,16 +154,16 @@ class Doctrine_Export_Mssql extends Doctrine_Export { foreach ($changes as $change_name => $change) { switch ($change_name) { - case 'add': - break; - case 'remove': - break; - case 'name': - case 'rename': - case 'change': - default: - return $db->raiseError(Doctrine::ERR_CANNOT_ALTER, null, null, - 'alterTable: change type "'.$change_name.'" not yet supported'); + case 'add': + break; + case 'remove': + break; + case 'name': + case 'rename': + case 'change': + default: + return $db->raiseError(Doctrine::ERR_CANNOT_ALTER, null, null, + 'alterTable: change type "'.$change_name.'" not yet supported'); } } diff --git a/lib/Doctrine/Export/Mysql.php b/lib/Doctrine/Export/Mysql.php index e1a07668c..0dd934685 100644 --- a/lib/Doctrine/Export/Mysql.php +++ b/lib/Doctrine/Export/Mysql.php @@ -236,7 +236,7 @@ class Doctrine_Export_Mysql extends Doctrine_Export case 'change': case 'rename': case 'name': - break; + break; default: throw new Doctrine_Export_Mysql_Exception('change type "'.$changeName.'" not yet supported'); } diff --git a/lib/Doctrine/Export/Oracle.php b/lib/Doctrine/Export/Oracle.php index a41ce3494..d458f6042 100644 --- a/lib/Doctrine/Export/Oracle.php +++ b/lib/Doctrine/Export/Oracle.php @@ -343,15 +343,15 @@ END; foreach ($changes as $changeName => $change) { switch ($changeName) { - case 'add': - case 'remove': - case 'change': - case 'name': - case 'rename': - break; - default: - return $this->conn->raiseError(MDB2_ERROR_CANNOT_ALTER, null, null, - 'change type "'.$changeName.'" not yet supported', __FUNCTION__); + case 'add': + case 'remove': + case 'change': + case 'name': + case 'rename': + break; + default: + return $this->conn->raiseError(MDB2_ERROR_CANNOT_ALTER, null, null, + 'change type "'.$changeName.'" not yet supported', __FUNCTION__); } } diff --git a/lib/Doctrine/Export/Pgsql.php b/lib/Doctrine/Export/Pgsql.php index bf471f8be..b793c4520 100644 --- a/lib/Doctrine/Export/Pgsql.php +++ b/lib/Doctrine/Export/Pgsql.php @@ -155,7 +155,7 @@ class Doctrine_Export_Pgsql extends Doctrine_Export case 'change': case 'name': case 'rename': - break; + break; default: throw new Doctrine_Export_Pgsql_Exception('change type "'.$change_name.'\" not yet supported'); } diff --git a/lib/Doctrine/Export/Sqlite.php b/lib/Doctrine/Export/Sqlite.php index fc577e8a3..847ca4e48 100644 --- a/lib/Doctrine/Export/Sqlite.php +++ b/lib/Doctrine/Export/Sqlite.php @@ -75,12 +75,12 @@ class Doctrine_Export_Sqlite extends Doctrine_Export $fieldString = $fieldName; if (isset($field['sorting'])) { switch ($field['sorting']) { - case 'ascending': - $fieldString .= ' ASC'; - break; - case 'descending': - $fieldString .= ' DESC'; - break; + case 'ascending': + $fieldString .= ' ASC'; + break; + case 'descending': + $fieldString .= ' DESC'; + break; } } $fields[] = $fieldString; diff --git a/lib/Doctrine/Expression/Mssql.php b/lib/Doctrine/Expression/Mssql.php index d908ee592..ab0f8df6c 100644 --- a/lib/Doctrine/Expression/Mssql.php +++ b/lib/Doctrine/Expression/Mssql.php @@ -45,11 +45,11 @@ class Doctrine_Expression_Mssql extends Doctrine_Expression public function now($type = 'timestamp') { switch ($type) { - case 'time': - case 'date': - case 'timestamp': - default: - return 'GETDATE()'; + case 'time': + case 'date': + case 'timestamp': + default: + return 'GETDATE()'; } } /** diff --git a/lib/Doctrine/Expression/Mysql.php b/lib/Doctrine/Expression/Mysql.php index 76f4fdf0f..f3d294cc8 100644 --- a/lib/Doctrine/Expression/Mysql.php +++ b/lib/Doctrine/Expression/Mysql.php @@ -65,16 +65,16 @@ class Doctrine_Expression_Mysql extends Doctrine_Expression $field = is_null($field) ? '' : $field.' '; $operator = strtoupper($operator); switch ($operator) { - // case insensitive - case 'ILIKE': - $match = $field.'LIKE '; - break; - // case sensitive - case 'LIKE': - $match = $field.'LIKE BINARY '; - break; - default: - throw new Doctrine_Expression_Mysql_Exception('not a supported operator type:'. $operator); + // case insensitive + case 'ILIKE': + $match = $field.'LIKE '; + break; + // case sensitive + case 'LIKE': + $match = $field.'LIKE BINARY '; + break; + default: + throw new Doctrine_Expression_Mysql_Exception('not a supported operator type:'. $operator); } } $match.= "'"; diff --git a/lib/Doctrine/Expression/Oracle.php b/lib/Doctrine/Expression/Oracle.php index 9f30514bf..3f7b39d8d 100644 --- a/lib/Doctrine/Expression/Oracle.php +++ b/lib/Doctrine/Expression/Oracle.php @@ -77,11 +77,11 @@ class Doctrine_Expression_Oracle extends Doctrine_Expression public function now($type = 'timestamp') { switch ($type) { - case 'date': - case 'time': - case 'timestamp': - default: - return 'TO_CHAR(CURRENT_TIMESTAMP, \'YYYY-MM-DD HH24:MI:SS\')'; + case 'date': + case 'time': + case 'timestamp': + default: + return 'TO_CHAR(CURRENT_TIMESTAMP, \'YYYY-MM-DD HH24:MI:SS\')'; } } /** diff --git a/lib/Doctrine/Expression/Pgsql.php b/lib/Doctrine/Expression/Pgsql.php index f8ca8fec6..8842d4f58 100644 --- a/lib/Doctrine/Expression/Pgsql.php +++ b/lib/Doctrine/Expression/Pgsql.php @@ -142,17 +142,17 @@ class Doctrine_Expression_Pgsql extends Doctrine_Expression $field = is_null($field) ? '' : $field.' '; $operator = strtoupper($operator); switch ($operator) { - // case insensitive - case 'ILIKE': - $match = $field.'ILIKE '; - break; - // case sensitive - case 'LIKE': - $match = $field.'LIKE '; - break; - default: - return $db->raiseError(MDB2_ERROR_UNSUPPORTED, null, null, - 'not a supported operator type:'. $operator, __FUNCTION__); + // case insensitive + case 'ILIKE': + $match = $field.'ILIKE '; + break; + // case sensitive + case 'LIKE': + $match = $field.'LIKE '; + break; + default: + return $db->raiseError(MDB2_ERROR_UNSUPPORTED, null, null, + 'not a supported operator type:'. $operator, __FUNCTION__); } } $match.= "'"; diff --git a/lib/Doctrine/Expression/Sqlite.php b/lib/Doctrine/Expression/Sqlite.php index 5fcf6d6f4..383382b18 100644 --- a/lib/Doctrine/Expression/Sqlite.php +++ b/lib/Doctrine/Expression/Sqlite.php @@ -125,13 +125,13 @@ class Doctrine_Expression_Sqlite extends Doctrine_Expression public function now($type = 'timestamp') { switch ($type) { - case 'time': - return 'time(\'now\')'; - case 'date': - return 'date(\'now\')'; - case 'timestamp': - default: - return 'datetime(\'now\')'; + case 'time': + return 'time(\'now\')'; + case 'date': + return 'date(\'now\')'; + case 'timestamp': + default: + return 'datetime(\'now\')'; } } /** diff --git a/lib/Doctrine/Hydrate.php b/lib/Doctrine/Hydrate.php index b6ef92ba2..b49ff2ec1 100644 --- a/lib/Doctrine/Hydrate.php +++ b/lib/Doctrine/Hydrate.php @@ -323,23 +323,23 @@ abstract class Doctrine_Hydrate extends Doctrine_Access return new Doctrine_Collection($table); } switch ($this->fetchModes[$name]) { - case Doctrine::FETCH_BATCH: - $coll = new Doctrine_Collection_Batch($table); - break; - case Doctrine::FETCH_LAZY: - $coll = new Doctrine_Collection_Lazy($table); - break; - case Doctrine::FETCH_OFFSET: - $coll = new Doctrine_Collection_Offset($table); - break; - case Doctrine::FETCH_IMMEDIATE: - $coll = new Doctrine_Collection_Immediate($table); - break; - case Doctrine::FETCH_LAZY_OFFSET: - $coll = new Doctrine_Collection_LazyOffset($table); - break; - default: - throw new Doctrine_Exception("Unknown fetchmode"); + case Doctrine::FETCH_BATCH: + $coll = new Doctrine_Collection_Batch($table); + break; + case Doctrine::FETCH_LAZY: + $coll = new Doctrine_Collection_Lazy($table); + break; + case Doctrine::FETCH_OFFSET: + $coll = new Doctrine_Collection_Offset($table); + break; + case Doctrine::FETCH_IMMEDIATE: + $coll = new Doctrine_Collection_Immediate($table); + break; + case Doctrine::FETCH_LAZY_OFFSET: + $coll = new Doctrine_Collection_LazyOffset($table); + break; + default: + throw new Doctrine_Exception("Unknown fetchmode"); }; return $coll; diff --git a/lib/Doctrine/Lib.php b/lib/Doctrine/Lib.php index b256b4368..467e98d09 100644 --- a/lib/Doctrine/Lib.php +++ b/lib/Doctrine/Lib.php @@ -39,21 +39,21 @@ class Doctrine_Lib public static function getRecordStateAsString($state) { switch ($state) { - case Doctrine_Record::STATE_PROXY: - return "proxy"; - break; - case Doctrine_Record::STATE_CLEAN: - return "persistent clean"; - break; - case Doctrine_Record::STATE_DIRTY: - return "persistent dirty"; - break; - case Doctrine_Record::STATE_TDIRTY: - return "transient dirty"; - break; - case Doctrine_Record::STATE_TCLEAN: - return "transient clean"; - break; + case Doctrine_Record::STATE_PROXY: + return "proxy"; + break; + case Doctrine_Record::STATE_CLEAN: + return "persistent clean"; + break; + case Doctrine_Record::STATE_DIRTY: + return "persistent dirty"; + break; + case Doctrine_Record::STATE_TDIRTY: + return "transient dirty"; + break; + case Doctrine_Record::STATE_TCLEAN: + return "transient clean"; + break; }; } /** @@ -80,15 +80,15 @@ class Doctrine_Lib public static function getConnectionStateAsString($state) { switch ($state) { - case Doctrine_Transaction::STATE_SLEEP: - return "open"; - break; - case Doctrine_Transaction::STATE_BUSY: - return "busy"; - break; - case Doctrine_Transaction::STATE_ACTIVE: - return "active"; - break; + case Doctrine_Transaction::STATE_SLEEP: + return "open"; + break; + case Doctrine_Transaction::STATE_BUSY: + return "busy"; + break; + case Doctrine_Transaction::STATE_ACTIVE: + return "active"; + break; }; } /** diff --git a/lib/Doctrine/Manager.php b/lib/Doctrine/Manager.php index 6600c79e7..962f66160 100644 --- a/lib/Doctrine/Manager.php +++ b/lib/Doctrine/Manager.php @@ -192,33 +192,33 @@ class Doctrine_Manager extends Doctrine_Configurable implements Countable, Itera $this->index++; } switch ($adapter->getAttribute(PDO::ATTR_DRIVER_NAME)) { - case 'mysql': - $this->connections[$name] = new Doctrine_Connection_Mysql($this, $adapter); - break; - case 'sqlite': - $this->connections[$name] = new Doctrine_Connection_Sqlite($this, $adapter); - break; - case 'pgsql': - $this->connections[$name] = new Doctrine_Connection_Pgsql($this, $adapter); - break; - case 'oci': - case 'oracle': - $this->connections[$name] = new Doctrine_Connection_Oracle($this, $adapter); - break; - case 'mssql': - $this->connections[$name] = new Doctrine_Connection_Mssql($this, $adapter); - break; - case 'firebird': - $this->connections[$name] = new Doctrine_Connection_Firebird($this, $adapter); - break; - case 'informix': - $this->connections[$name] = new Doctrine_Connection_Informix($this, $adapter); - break; - case 'mock': - $this->connections[$name] = new Doctrine_Connection_Mock($this, $adapter); - break; - default: - throw new Doctrine_Manager_Exception('Unknown connection driver '. $adapter->getAttribute(PDO::ATTR_DRIVER_NAME)); + case 'mysql': + $this->connections[$name] = new Doctrine_Connection_Mysql($this, $adapter); + break; + case 'sqlite': + $this->connections[$name] = new Doctrine_Connection_Sqlite($this, $adapter); + break; + case 'pgsql': + $this->connections[$name] = new Doctrine_Connection_Pgsql($this, $adapter); + break; + case 'oci': + case 'oracle': + $this->connections[$name] = new Doctrine_Connection_Oracle($this, $adapter); + break; + case 'mssql': + $this->connections[$name] = new Doctrine_Connection_Mssql($this, $adapter); + break; + case 'firebird': + $this->connections[$name] = new Doctrine_Connection_Firebird($this, $adapter); + break; + case 'informix': + $this->connections[$name] = new Doctrine_Connection_Informix($this, $adapter); + break; + case 'mock': + $this->connections[$name] = new Doctrine_Connection_Mock($this, $adapter); + break; + default: + throw new Doctrine_Manager_Exception('Unknown connection driver '. $adapter->getAttribute(PDO::ATTR_DRIVER_NAME)); }; $this->currIndex = $name; diff --git a/lib/Doctrine/Query/From.php b/lib/Doctrine/Query/From.php index 4a60e94fe..65153c6ab 100644 --- a/lib/Doctrine/Query/From.php +++ b/lib/Doctrine/Query/From.php @@ -48,10 +48,10 @@ class Doctrine_Query_From extends Doctrine_Query_Part $operator = false; switch (trim($parts[0])) { - case 'INNER': - $operator = ':'; - case 'LEFT': - array_shift($parts); + case 'INNER': + $operator = ':'; + case 'LEFT': + array_shift($parts); } $last = ''; diff --git a/lib/Doctrine/Query/Where.php b/lib/Doctrine/Query/Where.php index 551880bf4..0e00ad292 100644 --- a/lib/Doctrine/Query/Where.php +++ b/lib/Doctrine/Query/Where.php @@ -64,24 +64,24 @@ class Doctrine_Query_Where extends Doctrine_Query_Condition $stack = $this->query->getTableStack(); switch ($func) { - case 'contains': - case 'regexp': - case 'like': - $operator = $this->getOperator($func); - - if (empty($relation)) { - throw new Doctrine_Query_Exception('DQL functions contains/regexp/like can only be used for fields of related components'); - } - $where = array(); - foreach ($values as $value) { - $where[] = $alias.'.'.$relation->getLocal(). - ' IN (SELECT '.$relation->getForeign(). - ' FROM '.$relation->getTable()->getTableName().' WHERE '.$field.$operator.$value.')'; - } - $where = implode(' AND ', $where); - break; - default: - throw new Doctrine_Query_Exception('Unknown DQL function: '.$func); + case 'contains': + case 'regexp': + case 'like': + $operator = $this->getOperator($func); + + if (empty($relation)) { + throw new Doctrine_Query_Exception('DQL functions contains/regexp/like can only be used for fields of related components'); + } + $where = array(); + foreach ($values as $value) { + $where[] = $alias.'.'.$relation->getLocal(). + ' IN (SELECT '.$relation->getForeign(). + ' FROM '.$relation->getTable()->getTableName().' WHERE '.$field.$operator.$value.')'; + } + $where = implode(' AND ', $where); + break; + default: + throw new Doctrine_Query_Exception('Unknown DQL function: '.$func); } } else { $table = $this->query->load($reference, false); @@ -124,15 +124,15 @@ class Doctrine_Query_Where extends Doctrine_Query_Condition } switch ($operator) { - case '<': - case '>': - case '=': - case '!=': - if ($enumIndex !== false) { - $value = $enumIndex; - } - default: - $where = $alias.'.'.$field.' '.$operator.' '.$value; + case '<': + case '>': + case '=': + case '!=': + if ($enumIndex !== false) { + $value = $enumIndex; + } + default: + $where = $alias.'.'.$field.' '.$operator.' '.$value; } } } @@ -202,15 +202,15 @@ class Doctrine_Query_Where extends Doctrine_Query_Condition public function getOperator($func) { switch ($func) { - case 'contains': - $operator = ' = '; - break; - case 'regexp': - $operator = $this->query->getConnection()->getRegexpOperator(); - break; - case 'like': - $operator = ' LIKE '; - break; + case 'contains': + $operator = ' = '; + break; + case 'regexp': + $operator = $this->query->getConnection()->getRegexpOperator(); + break; + case 'like': + $operator = ' LIKE '; + break; } return $operator; } diff --git a/lib/Doctrine/RawSql.php b/lib/Doctrine/RawSql.php index e76824ffb..6a827ad31 100644 --- a/lib/Doctrine/RawSql.php +++ b/lib/Doctrine/RawSql.php @@ -87,37 +87,37 @@ class Doctrine_RawSql extends Doctrine_Hydrate foreach ($e as $k => $part) { $low = strtolower($part); switch (strtolower($part)) { - case "select": - case "from": - case "where": - case "limit": - case "offset": - 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") { + case "select": + case "from": + case "where": + case "limit": + case "offset": + case "having": $p = $low; - $p .= "by"; - $parts[$low."by"] = array(); - - } else { - $parts[$p][] = $part; - } - break; - case "by": - continue; - default: - if ( ! isset($parts[$p][0])) { - $parts[$p][0] = $part; - } else { - $parts[$p][0] .= ' '.$part; - } + 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 .= "by"; + $parts[$low."by"] = array(); + + } else { + $parts[$p][] = $part; + } + break; + case "by": + continue; + default: + if ( ! isset($parts[$p][0])) { + $parts[$p][0] = $part; + } else { + $parts[$p][0] .= ' '.$part; + } }; }; diff --git a/lib/Doctrine/Record.php b/lib/Doctrine/Record.php index 9154c336a..6b2502a98 100644 --- a/lib/Doctrine/Record.php +++ b/lib/Doctrine/Record.php @@ -373,37 +373,35 @@ abstract class Doctrine_Record extends Doctrine_Access implements Countable, Ite $this->_data[$name] = self::$null; } else { switch ($type) { - case "array": - case "object": - - if ($tmp[$name] !== self::$null) { - if (is_string($tmp[$name])) { - $value = unserialize($tmp[$name]); - - if ($value === false) - throw new Doctrine_Record_Exception("Unserialization of $name failed."); - } else { - $value = $tmp[$name]; + case "array": + case "object": + if ($tmp[$name] !== self::$null) { + if (is_string($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; } - $this->_data[$name] = $value; - } - break; - case "gzip": - - if ($tmp[$name] !== self::$null) { - $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]; + break; + case "gzip": + if ($tmp[$name] !== self::$null) { + $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++; } @@ -421,38 +419,38 @@ abstract class Doctrine_Record extends Doctrine_Access implements Countable, Ite private function prepareIdentifiers($exists = true) { switch ($this->_table->getIdentifierType()) { - case Doctrine_Identifier::AUTO_INCREMENT: - case Doctrine_Identifier::SEQUENCE: - $name = $this->_table->getIdentifier(); - - if ($exists) { + case Doctrine_Identifier::AUTO_INCREMENT: + case Doctrine_Identifier::SEQUENCE: + $name = $this->_table->getIdentifier(); + + 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) { $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) { - $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; + 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 $this->_data = array_merge($this->_data, $this->_id); foreach ($this->_data as $k => $v) { - if ($v instanceof Doctrine_Record) + if ($v instanceof Doctrine_Record) { unset($vars['_data'][$k]); - elseif ($v === self::$null) { + } elseif ($v === self::$null) { unset($vars['_data'][$k]); } else { switch ($this->_table->getTypeOf($k)) { - case "array": - case "object": - $vars['_data'][$k] = serialize($vars['_data'][$k]); - break; + case "array": + case "object": + $vars['_data'][$k] = serialize($vars['_data'][$k]); + break; }; } } @@ -560,16 +558,16 @@ abstract class Doctrine_Record extends Doctrine_Access implements Countable, Ite } elseif (is_string($state)) { $upper = strtoupper($state); switch ($upper) { - case 'DIRTY': - case 'CLEAN': - case 'TDIRTY': - case 'TCLEAN': - case 'PROXY': - case 'DELETED': - $this->_state = constant('Doctrine_Record::STATE_' . $upper); - break; - default: - $err = true; + case 'DIRTY': + case 'CLEAN': + case 'TDIRTY': + case 'TCLEAN': + case 'PROXY': + case 'DELETED': + $this->_state = constant('Doctrine_Record::STATE_' . $upper); + break; + default: + $err = true; } } @@ -819,12 +817,12 @@ abstract class Doctrine_Record extends Doctrine_Access implements Countable, Ite $this->_data[$lower] = $value; $this->_modified[] = $lower; switch ($this->_state) { - case Doctrine_Record::STATE_CLEAN: - $this->_state = Doctrine_Record::STATE_DIRTY; - break; - case Doctrine_Record::STATE_TCLEAN: - $this->_state = Doctrine_Record::STATE_TDIRTY; - break; + case Doctrine_Record::STATE_CLEAN: + $this->_state = Doctrine_Record::STATE_DIRTY; + break; + case Doctrine_Record::STATE_TCLEAN: + $this->_state = Doctrine_Record::STATE_TDIRTY; + break; }; } } else { @@ -1007,24 +1005,24 @@ abstract class Doctrine_Record extends Doctrine_Access implements Countable, Ite } switch ($type) { - case 'array': - case 'object': - $a[$v] = serialize($this->_data[$v]); + case 'array': + case 'object': + $a[$v] = serialize($this->_data[$v]); + break; + case 'gzip': + $a[$v] = gzcompress($this->_data[$v],5); + break; + case 'boolean': + $a[$v] = (int) $this->_data[$v]; break; - case 'gzip': - $a[$v] = gzcompress($this->_data[$v],5); - break; - case 'boolean': - $a[$v] = (int) $this->_data[$v]; - break; - case 'enum': - $a[$v] = $this->_table->enumIndex($v,$this->_data[$v]); - break; - default: - if ($this->_data[$v] instanceof Doctrine_Record) - $this->_data[$v] = $this->_data[$v]->getIncremented(); - - $a[$v] = $this->_data[$v]; + case 'enum': + $a[$v] = $this->_table->enumIndex($v,$this->_data[$v]); + break; + default: + if ($this->_data[$v] instanceof Doctrine_Record) + $this->_data[$v] = $this->_data[$v]->getIncremented(); + + $a[$v] = $this->_data[$v]; } } diff --git a/lib/Doctrine/Relation/Association.php b/lib/Doctrine/Relation/Association.php index d776a8569..2c6d9677e 100644 --- a/lib/Doctrine/Relation/Association.php +++ b/lib/Doctrine/Relation/Association.php @@ -107,21 +107,21 @@ class Doctrine_Relation_Association extends Doctrine_Relation public function getRelationDql($count, $context = 'record') { switch ($context) { - case "record": - $sub = 'SQL:SELECT ' . $this->foreign. - ' FROM ' . $this->associationTable->getTableName(). - ' WHERE ' . $this->local. - ' IN (' . substr(str_repeat("?, ", $count),0,-2) . - ')'; - - $dql = "FROM ".$this->table->getComponentName(); - $dql .= ".".$this->associationTable->getComponentName(); - $dql .= " WHERE ".$this->table->getComponentName().".".$this->table->getIdentifier()." IN ($sub)"; - break; - case "collection": - $sub = substr(str_repeat("?, ", $count),0,-2); - $dql = "FROM ".$this->associationTable->getComponentName().".".$this->table->getComponentName(); - $dql .= " WHERE ".$this->associationTable->getComponentName().".".$this->local." IN ($sub)"; + case "record": + $sub = 'SQL:SELECT ' . $this->foreign. + ' FROM ' . $this->associationTable->getTableName(). + ' WHERE ' . $this->local. + ' IN (' . substr(str_repeat("?, ", $count),0,-2) . + ')'; + + $dql = "FROM ".$this->table->getComponentName(); + $dql .= ".".$this->associationTable->getComponentName(); + $dql .= " WHERE ".$this->table->getComponentName().".".$this->table->getIdentifier()." IN ($sub)"; + break; + case "collection": + $sub = substr(str_repeat("?, ", $count),0,-2); + $dql = "FROM ".$this->associationTable->getComponentName().".".$this->table->getComponentName(); + $dql .= " WHERE ".$this->associationTable->getComponentName().".".$this->local." IN ($sub)"; }; return $dql; diff --git a/lib/Doctrine/Relation/Association/Self.php b/lib/Doctrine/Relation/Association/Self.php index d3a547f20..fcff48e9c 100644 --- a/lib/Doctrine/Relation/Association/Self.php +++ b/lib/Doctrine/Relation/Association/Self.php @@ -41,25 +41,25 @@ class Doctrine_Relation_Association_Self extends Doctrine_Relation_Association public function getRelationDql($count, $context = 'record') { switch ($context) { - case 'record': - $sub = 'SELECT '.$this->foreign. - ' FROM '.$this->associationTable->getTableName(). - ' WHERE '.$this->local. - ' = ?'; - $sub2 = 'SELECT '.$this->local. - ' FROM '.$this->associationTable->getTableName(). - ' WHERE '.$this->foreign. - ' = ?'; - - $dql = 'FROM '.$this->table->getComponentName(); - $dql .= '.'.$this->associationTable->getComponentName(); - $dql .= ' WHERE '.$this->table->getComponentName().'.'.$this->table->getIdentifier().' IN ('.$sub.')'; - $dql .= ' || '.$this->table->getComponentName().'.'.$this->table->getIdentifier().' IN ('.$sub2.')'; - break; - case 'collection': - $sub = substr(str_repeat('?, ', $count),0,-2); - $dql = 'FROM '.$this->associationTable->getComponentName().'.'.$this->table->getComponentName(); - $dql .= ' WHERE '.$this->associationTable->getComponentName().'.'.$this->local.' IN ('.$sub.')'; + case 'record': + $sub = 'SELECT '.$this->foreign. + ' FROM '.$this->associationTable->getTableName(). + ' WHERE '.$this->local. + ' = ?'; + $sub2 = 'SELECT '.$this->local. + ' FROM '.$this->associationTable->getTableName(). + ' WHERE '.$this->foreign. + ' = ?'; + + $dql = 'FROM '.$this->table->getComponentName(); + $dql .= '.'.$this->associationTable->getComponentName(); + $dql .= ' WHERE '.$this->table->getComponentName().'.'.$this->table->getIdentifier().' IN ('.$sub.')'; + $dql .= ' || '.$this->table->getComponentName().'.'.$this->table->getIdentifier().' IN ('.$sub2.')'; + break; + case 'collection': + $sub = substr(str_repeat('?, ', $count),0,-2); + $dql = 'FROM '.$this->associationTable->getComponentName().'.'.$this->table->getComponentName(); + $dql .= ' WHERE '.$this->associationTable->getComponentName().'.'.$this->local.' IN ('.$sub.')'; }; return $dql; diff --git a/lib/Doctrine/Table.php b/lib/Doctrine/Table.php index 5579d9d05..2b5bc7884 100644 --- a/lib/Doctrine/Table.php +++ b/lib/Doctrine/Table.php @@ -187,55 +187,55 @@ class Doctrine_Table extends Doctrine_Configurable implements Countable $this->options['tableName'] = Doctrine::tableize($class->getName()); } switch (count($this->primaryKeys)) { - case 0: - $this->columns = array_merge(array('id' => - array('integer', - 20, - array('autoincrement' => true, - 'primary' => true - ) - ) - ), $this->columns); - - $this->primaryKeys[] = 'id'; - $this->identifier = 'id'; - $this->identifierType = Doctrine_Identifier::AUTO_INCREMENT; - $this->columnCount++; - break; - default: - if (count($this->primaryKeys) > 1) { - $this->identifier = $this->primaryKeys; - $this->identifierType = Doctrine_Identifier::COMPOSITE; - - } else { - foreach ($this->primaryKeys as $pk) { - $e = $this->columns[$pk][2]; - - $found = false; - - foreach ($e as $option => $value) { - if ($found) - break; - - $e2 = explode(":",$option); - - switch (strtolower($e2[0])) { - case "autoincrement": - $this->identifierType = Doctrine_Identifier::AUTO_INCREMENT; - $found = true; - break; - case "seq": - $this->identifierType = Doctrine_Identifier::SEQUENCE; - $found = true; - break; - }; + case 0: + $this->columns = array_merge(array('id' => + array('integer', + 20, + array('autoincrement' => true, + 'primary' => true + ) + ) + ), $this->columns); + + $this->primaryKeys[] = 'id'; + $this->identifier = 'id'; + $this->identifierType = Doctrine_Identifier::AUTO_INCREMENT; + $this->columnCount++; + break; + default: + if (count($this->primaryKeys) > 1) { + $this->identifier = $this->primaryKeys; + $this->identifierType = Doctrine_Identifier::COMPOSITE; + + } else { + foreach ($this->primaryKeys as $pk) { + $e = $this->columns[$pk][2]; + + $found = false; + + foreach ($e as $option => $value) { + if ($found) + break; + + $e2 = explode(":",$option); + + switch (strtolower($e2[0])) { + case "autoincrement": + $this->identifierType = Doctrine_Identifier::AUTO_INCREMENT; + $found = true; + break; + case "seq": + $this->identifierType = Doctrine_Identifier::SEQUENCE; + $found = true; + break; + }; + } + if ( ! isset($this->identifierType)) { + $this->identifierType = Doctrine_Identifier::NORMAL; + } + $this->identifier = $pk; } - if ( ! isset($this->identifierType)) { - $this->identifierType = Doctrine_Identifier::NORMAL; - } - $this->identifier = $pk; } - } }; if ($this->getAttribute(Doctrine::ATTR_CREATE_TABLES)) { @@ -306,15 +306,15 @@ class Doctrine_Table extends Doctrine_Configurable implements Countable public function setOption($name, $value) { switch ($name) { - case 'name': - case 'tableName': - break; - case 'enumMap': - case 'inheritanceMap': - if ( ! is_array($value)) { - throw new Doctrine_Table_Exception($name.' should be an array.'); - } - break; + case 'name': + case 'tableName': + break; + case 'enumMap': + case 'inheritanceMap': + if ( ! is_array($value)) { + throw new Doctrine_Table_Exception($name.' should be an array.'); + } + break; } $this->options[$name] = $value; } @@ -422,12 +422,12 @@ class Doctrine_Table extends Doctrine_Configurable implements Countable final public function setPrimaryKey($key) { switch (gettype($key)) { - case "array": - $this->primaryKeys = array_values($key); - break; - case "string": - $this->primaryKeys[] = $key; - break; + case "array": + $this->primaryKeys = array_values($key); + break; + case "string": + $this->primaryKeys[] = $key; + break; }; } /** @@ -491,20 +491,20 @@ class Doctrine_Table extends Doctrine_Configurable implements Countable $name = $this->getComponentName(); foreach ($this->bound as $k=>$a) { try { - $fk = $this->getRelation($k); - switch ($fk->getType()) { - case Doctrine_Relation::ONE_COMPOSITE: - case Doctrine_Relation::MANY_COMPOSITE: - $n = $fk->getTable()->getComponentName(); - $array[] = $name.".".$n; - $e = $fk->getTable()->getCompositePaths(); - if ( ! empty($e)) { - foreach ($e as $name) { - $array[] = $name.".".$n.".".$name; - } - } - break; - }; + $fk = $this->getRelation($k); + switch ($fk->getType()) { + case Doctrine_Relation::ONE_COMPOSITE: + case Doctrine_Relation::MANY_COMPOSITE: + $n = $fk->getTable()->getComponentName(); + $array[] = $name.".".$n; + $e = $fk->getTable()->getCompositePaths(); + if ( ! empty($e)) { + foreach ($e as $name) { + $array[] = $name.".".$n.".".$name; + } + } + break; + }; } catch(Doctrine_Table_Exception $e) { } diff --git a/lib/Doctrine/Transaction.php b/lib/Doctrine/Transaction.php index 692843995..3f3c67fb3 100644 --- a/lib/Doctrine/Transaction.php +++ b/lib/Doctrine/Transaction.php @@ -71,14 +71,14 @@ class Doctrine_Transaction extends Doctrine_Connection_Module public function getState() { switch ($this->transactionLevel) { - case 0: - return Doctrine_Transaction::STATE_SLEEP; - break; - case 1: - return Doctrine_Transaction::STATE_ACTIVE; - break; - default: - return Doctrine_Transaction::STATE_BUSY; + case 0: + return Doctrine_Transaction::STATE_SLEEP; + break; + case 1: + return Doctrine_Transaction::STATE_ACTIVE; + break; + default: + return Doctrine_Transaction::STATE_BUSY; } } /** diff --git a/lib/Doctrine/Transaction/Firebird.php b/lib/Doctrine/Transaction/Firebird.php index 710f4f9e4..cfb741c56 100644 --- a/lib/Doctrine/Transaction/Firebird.php +++ b/lib/Doctrine/Transaction/Firebird.php @@ -92,16 +92,16 @@ class Doctrine_Transaction_Firebird extends Doctrine_Transaction switch ($isolation) { case 'READ UNCOMMITTED': $nativeIsolation = 'READ COMMITTED RECORD_VERSION'; - break; + break; case 'READ COMMITTED': $nativeIsolation = 'READ COMMITTED NO RECORD_VERSION'; - break; + break; case 'REPEATABLE READ': $nativeIsolation = 'SNAPSHOT'; - break; + break; case 'SERIALIZABLE': $nativeIsolation = 'SNAPSHOT TABLE STABILITY'; - break; + break; default: throw new Doctrine_Transaction_Exception('isolation level is not supported: ' . $isolation); } @@ -124,7 +124,7 @@ class Doctrine_Transaction_Firebird extends Doctrine_Transaction case 'READ ONLY': case 'READ WRITE': $rw = ' ' . $options['rw']; - break; + break; default: throw new Doctrine_Transaction_Exception('wait option is not supported: ' . $options['rw']); } diff --git a/lib/Doctrine/Transaction/Mssql.php b/lib/Doctrine/Transaction/Mssql.php index e7d72bf7c..6ee46dc5e 100644 --- a/lib/Doctrine/Transaction/Mssql.php +++ b/lib/Doctrine/Transaction/Mssql.php @@ -56,8 +56,7 @@ class Doctrine_Transaction_Mssql extends Doctrine_Transaction case 'REPEATABLE READ': case 'SERIALIZABLE': case 'SNAPSHOT': - - break; + break; default: throw new Doctrine_Transaction_Exception('isolation level is not supported: ' . $isolation); } diff --git a/lib/Doctrine/Transaction/Mysql.php b/lib/Doctrine/Transaction/Mysql.php index de70f6d3f..e0cec49f1 100644 --- a/lib/Doctrine/Transaction/Mysql.php +++ b/lib/Doctrine/Transaction/Mysql.php @@ -91,8 +91,7 @@ class Doctrine_Transaction_Mysql extends Doctrine_Transaction case 'READ COMMITTED': case 'REPEATABLE READ': case 'SERIALIZABLE': - - break; + break; default: throw new Doctrine_Transaction_Exception('Isolation level ' . $isolation . ' is not supported.'); } diff --git a/lib/Doctrine/Transaction/Oracle.php b/lib/Doctrine/Transaction/Oracle.php index 8ace36fdd..164f7a3b6 100644 --- a/lib/Doctrine/Transaction/Oracle.php +++ b/lib/Doctrine/Transaction/Oracle.php @@ -85,16 +85,16 @@ class Doctrine_Transaction_Oracle extends Doctrine_Transaction public function setIsolation($isolation) { switch ($isolation) { - case 'READ UNCOMMITTED': - $isolation = 'READ COMMITTED'; - break; - case 'READ COMMITTED': - case 'REPEATABLE READ': - case 'SERIALIZABLE': - $isolation = 'SERIALIZABLE'; - break; - default: - throw new Doctrine_Transaction_Exception('Isolation level ' . $isolation . ' is not supported.'); + case 'READ UNCOMMITTED': + $isolation = 'READ COMMITTED'; + break; + case 'READ COMMITTED': + case 'REPEATABLE READ': + case 'SERIALIZABLE': + $isolation = 'SERIALIZABLE'; + break; + default: + throw new Doctrine_Transaction_Exception('Isolation level ' . $isolation . ' is not supported.'); } $query = 'ALTER SESSION ISOLATION LEVEL ' . $isolation; diff --git a/lib/Doctrine/Transaction/Pgsql.php b/lib/Doctrine/Transaction/Pgsql.php index 1f85462da..4c8147740 100644 --- a/lib/Doctrine/Transaction/Pgsql.php +++ b/lib/Doctrine/Transaction/Pgsql.php @@ -91,8 +91,7 @@ class Doctrine_Transaction_Pgsql extends Doctrine_Transaction case 'READ COMMITTED': case 'REPEATABLE READ': case 'SERIALIZABLE': - - break; + break; default: throw new Doctrine_Transaction_Exception('Isolation level '.$isolation.' is not supported.'); } diff --git a/lib/Doctrine/Transaction/Sqlite.php b/lib/Doctrine/Transaction/Sqlite.php index 0b9820a6f..ba67706f9 100644 --- a/lib/Doctrine/Transaction/Sqlite.php +++ b/lib/Doctrine/Transaction/Sqlite.php @@ -49,12 +49,12 @@ class Doctrine_Transaction_Sqlite extends Doctrine_Transaction switch ($isolation) { case 'READ UNCOMMITTED': $isolation = 0; - break; + break; case 'READ COMMITTED': case 'REPEATABLE READ': case 'SERIALIZABLE': $isolation = 1; - break; + break; default: throw new Doctrine_Transaction_Exception('Isolation level ' . $isolation . 'is not supported.'); } diff --git a/lib/Doctrine/Validator.php b/lib/Doctrine/Validator.php index 2d9801d07..b6ee485f6 100644 --- a/lib/Doctrine/Validator.php +++ b/lib/Doctrine/Validator.php @@ -211,18 +211,18 @@ class Doctrine_Validator public static function phpType($doctrineType) { switch ($doctrineType) { - case 'enum': - return 'integer'; - case 'blob': - case 'clob': - case 'mbstring': - case 'timestamp': - case 'date': - case 'gzip': - return 'string'; - break; - default: - return $doctrineType; + case 'enum': + return 'integer'; + case 'blob': + case 'clob': + case 'mbstring': + case 'timestamp': + case 'date': + case 'gzip': + return 'string'; + break; + default: + return $doctrineType; } } /** @@ -242,19 +242,19 @@ class Doctrine_Validator $type = self::phpType($type); switch ($looseType) { - case 'float': - case 'double': - case 'integer': - if ($type == 'string' || $type == 'float') + case 'float': + case 'double': + case 'integer': + if ($type == 'string' || $type == 'float') + return true; + case 'string': + case 'array': + case 'object': + return ($type === $looseType); + break; + case 'NULL': return true; - case 'string': - case 'array': - case 'object': - return ($type === $looseType); - break; - case 'NULL': - return true; - break; + break; }; } /** @@ -267,17 +267,17 @@ class Doctrine_Validator { $type = gettype($var); switch ($type) { - case 'string': - if (preg_match("/^[0-9]+$/",$var)) { - return 'integer'; - } elseif (is_numeric($var)) { - return 'float'; - } else { + case 'string': + if (preg_match("/^[0-9]+$/",$var)) { + return 'integer'; + } elseif (is_numeric($var)) { + return 'float'; + } else { + return $type; + } + break; + default: return $type; - } - break; - default: - return $type; }; } }