From 9e6ea208f24419bbf14e9d28063855711d3422cf Mon Sep 17 00:00:00 2001 From: zYne Date: Thu, 25 Jan 2007 22:36:43 +0000 Subject: [PATCH] updated export drivers + removed unnecessary exceptions --- lib/Doctrine/Export/Firebird.php | 32 ++++++++++---------- lib/Doctrine/Export/Firebird/Exception.php | 34 ---------------------- lib/Doctrine/Export/Informix/Exception.php | 34 ---------------------- lib/Doctrine/Export/Mssql.php | 3 +- lib/Doctrine/Export/Mssql/Exception.php | 34 ---------------------- lib/Doctrine/Export/Mysql.php | 8 ++--- lib/Doctrine/Export/Mysql/Exception.php | 34 ---------------------- lib/Doctrine/Export/Oracle.php | 10 +++---- lib/Doctrine/Export/Oracle/Exception.php | 34 ---------------------- lib/Doctrine/Export/Pgsql.php | 4 +-- lib/Doctrine/Export/Pgsql/Exception.php | 33 --------------------- lib/Doctrine/Export/Sqlite/Exception.php | 34 ---------------------- 12 files changed, 29 insertions(+), 265 deletions(-) delete mode 100644 lib/Doctrine/Export/Firebird/Exception.php delete mode 100644 lib/Doctrine/Export/Informix/Exception.php delete mode 100644 lib/Doctrine/Export/Mssql/Exception.php delete mode 100644 lib/Doctrine/Export/Mysql/Exception.php delete mode 100644 lib/Doctrine/Export/Oracle/Exception.php delete mode 100644 lib/Doctrine/Export/Pgsql/Exception.php delete mode 100644 lib/Doctrine/Export/Sqlite/Exception.php diff --git a/lib/Doctrine/Export/Firebird.php b/lib/Doctrine/Export/Firebird.php index 24c6c6fea..b19a5c8fc 100644 --- a/lib/Doctrine/Export/Firebird.php +++ b/lib/Doctrine/Export/Firebird.php @@ -42,7 +42,7 @@ class Doctrine_Export_Firebird extends Doctrine_Export */ public function createDatabase($name) { - throw new Doctrine_Export_Firebird_Exception( + throw new Doctrine_Export_Exception( 'PHP Interbase API does not support direct queries. You have to ' . 'create the db manually by using isql command or a similar program'); } @@ -54,7 +54,7 @@ class Doctrine_Export_Firebird extends Doctrine_Export */ public function dropDatabase($name) { - throw new Doctrine_Export_Firebird_Exception( + throw new Doctrine_Export_Exception( 'PHP Interbase API does not support direct queries. You have ' . 'to drop the db manually by using isql command or a similar program'); } @@ -112,8 +112,9 @@ class Doctrine_Export_Firebird extends Doctrine_Export //remove autoincrement trigger associated with the table $table = $this->conn->quote(strtoupper($table)); - $trigger_name = $this->conn->quote(strtoupper($table) . '_AUTOINCREMENT_PK'); - return $this->conn->exec("DELETE FROM RDB\$TRIGGERS WHERE UPPER(RDB\$RELATION_NAME)=$table AND UPPER(RDB\$TRIGGER_NAME)=$trigger_name"); + $triggerName = $this->conn->quote(strtoupper($table) . '_AUTOINCREMENT_PK'); + + return $this->conn->exec("DELETE FROM RDB\$TRIGGERS WHERE UPPER(RDB\$RELATION_NAME)=" . $table . " AND UPPER(RDB\$TRIGGER_NAME)=" . $triggerName); } /** * create a new table @@ -177,9 +178,9 @@ class Doctrine_Export_Firebird extends Doctrine_Export foreach ($changes as $change_name => $change) { switch ($change_name) { case 'notnull': - throw new Doctrine_DataDict_Firebird_Exception('it is not supported changes to field not null constraint'); + throw new Doctrine_DataDict_Exception('it is not supported changes to field not null constraint'); case 'default': - throw new Doctrine_DataDict_Firebird_Exception('it is not supported changes to field default value'); + throw new Doctrine_DataDict_Exception('it is not supported changes to field default value'); case 'length': /* return throw new Doctrine_DataDict_Firebird_Exception('it is not supported changes to field default length'); @@ -190,7 +191,7 @@ class Doctrine_Export_Firebird extends Doctrine_Export case 'definition': break; default: - throw new Doctrine_DataDict_Firebird_Exception('it is not supported change of type' . $change_name); + throw new Doctrine_DataDict_Exception('it is not supported change of type' . $change_name); } } return true; @@ -313,7 +314,7 @@ class Doctrine_Export_Firebird extends Doctrine_Export } break; default: - throw new Doctrine_DataDict_Firebird_Exception('change type ' . $change_name . ' not yet supported'); + throw new Doctrine_DataDict_Exception('change type ' . $change_name . ' not yet supported'); } } if ($check) { @@ -325,7 +326,7 @@ class Doctrine_Export_Firebird extends Doctrine_Export if ($query) { $query.= ', '; } - $query.= 'ADD ' . $this->conn->getDeclaration($field['type'], $field_name, $field, $name); + $query.= 'ADD ' . $this->getDeclaration($field['type'], $field_name, $field, $name); } } @@ -358,7 +359,7 @@ class Doctrine_Export_Firebird extends Doctrine_Export } $this->conn->loadModule('Datatype', null, true); $field_name = $this->conn->quoteIdentifier($field_name, true); - $query.= 'ALTER ' . $field_name.' TYPE ' . $this->conn->datatype->getTypeDeclaration($field['definition']); + $query.= 'ALTER ' . $field_name.' TYPE ' . $this->getTypeDeclaration($field['definition']); } } @@ -501,14 +502,15 @@ class Doctrine_Export_Firebird extends Doctrine_Export /** * drop existing sequence * - * @param string $seq_name name of the sequence to be dropped + * @param string $seqName name of the sequence to be dropped * @return void */ - public function dropSequence($seq_name) + public function dropSequence($seqName) { - $sequence_name = $this->conn->getSequenceName($seq_name); - $sequence_name = $this->conn->quote($sequence_name); - $query = "DELETE FROM RDB\$GENERATORS WHERE UPPER(RDB\$GENERATOR_NAME)=$sequence_name"; + $sequenceName = $this->conn->getSequenceName($seqName); + $sequenceName = $this->conn->quote($sequenceName); + $query = "DELETE FROM RDB\$GENERATORS WHERE UPPER(RDB\$GENERATOR_NAME)=" . $sequenceName; + return $this->conn->exec($query); } } diff --git a/lib/Doctrine/Export/Firebird/Exception.php b/lib/Doctrine/Export/Firebird/Exception.php deleted file mode 100644 index 1bab7d805..000000000 --- a/lib/Doctrine/Export/Firebird/Exception.php +++ /dev/null @@ -1,34 +0,0 @@ -. - */ -Doctrine::autoload('Doctrine_Export_Exception'); -/** - * Doctrine_Export_Firebird_Exception - * - * @package Doctrine - * @license http://www.opensource.org/licenses/lgpl-license.php LGPL - * @category Object Relational Mapping - * @link www.phpdoctrine.com - * @since 1.0 - * @version $Revision$ - * @author Konsta Vesterinen - */ -class Doctrine_Export_Firebird_Exception extends Doctrine_Export_Exception -{ } diff --git a/lib/Doctrine/Export/Informix/Exception.php b/lib/Doctrine/Export/Informix/Exception.php deleted file mode 100644 index 44acf0cd7..000000000 --- a/lib/Doctrine/Export/Informix/Exception.php +++ /dev/null @@ -1,34 +0,0 @@ -. - */ -Doctrine::autoload('Doctrine_Export_Exception'); -/** - * Doctrine_Export_Informix_Exception - * - * @package Doctrine - * @license http://www.opensource.org/licenses/lgpl-license.php LGPL - * @category Object Relational Mapping - * @link www.phpdoctrine.com - * @since 1.0 - * @version $Revision$ - * @author Konsta Vesterinen - */ -class Doctrine_Export_Informix_Exception extends Doctrine_Export_Exception -{ } diff --git a/lib/Doctrine/Export/Mssql.php b/lib/Doctrine/Export/Mssql.php index cb3b5a2fa..b0afb73e0 100644 --- a/lib/Doctrine/Export/Mssql.php +++ b/lib/Doctrine/Export/Mssql.php @@ -162,8 +162,7 @@ class Doctrine_Export_Mssql extends Doctrine_Export case 'rename': case 'change': default: - return $this->conn->raiseError(Doctrine::ERR_CANNOT_ALTER, null, null, - 'alterTable: change type "'.$change_name.'" not yet supported'); + throw new Doctrine_Export_Exception('alterTable: change type "' . $change_name . '" not yet supported'); } } diff --git a/lib/Doctrine/Export/Mssql/Exception.php b/lib/Doctrine/Export/Mssql/Exception.php deleted file mode 100644 index d39911afd..000000000 --- a/lib/Doctrine/Export/Mssql/Exception.php +++ /dev/null @@ -1,34 +0,0 @@ -. - */ -Doctrine::autoload('Doctrine_Export_Exception'); -/** - * Doctrine_Export_Mssql_Exception - * - * @package Doctrine - * @license http://www.opensource.org/licenses/lgpl-license.php LGPL - * @category Object Relational Mapping - * @link www.phpdoctrine.com - * @since 1.0 - * @version $Revision$ - * @author Konsta Vesterinen - */ -class Doctrine_Export_Mssql_Exception extends Doctrine_Export_Exception -{ } diff --git a/lib/Doctrine/Export/Mysql.php b/lib/Doctrine/Export/Mysql.php index 17cd8aa1b..a7923eb2d 100644 --- a/lib/Doctrine/Export/Mysql.php +++ b/lib/Doctrine/Export/Mysql.php @@ -257,7 +257,7 @@ class Doctrine_Export_Mysql extends Doctrine_Export if ($query) { $query.= ', '; } - $query.= 'ADD ' . $this->dbh->getDeclaration($field['type'], $field_name, $field); + $query.= 'ADD ' . $this->getDeclaration($field['type'], $field_name, $field); } } @@ -290,7 +290,7 @@ class Doctrine_Export_Mysql extends Doctrine_Export $old_field_name = $field_name; } $old_field_name = $this->conn->quoteIdentifier($old_field_name, true); - $query.= "CHANGE $old_field_name " . $this->dbh->getDeclaration($field['definition']['type'], $field_name, $field['definition']); + $query.= "CHANGE $old_field_name " . $this->getDeclaration($field['definition']['type'], $field_name, $field['definition']); } } @@ -301,7 +301,7 @@ class Doctrine_Export_Mysql extends Doctrine_Export } $field = $changes['rename'][$renamed_field]; $renamed_field = $this->conn->quoteIdentifier($renamed_field, true); - $query.= 'CHANGE ' . $renamed_field . ' ' . $this->dbh->getDeclaration($field['definition']['type'], $field['name'], $field['definition']); + $query.= 'CHANGE ' . $renamed_field . ' ' . $this->getDeclaration($field['definition']['type'], $field['name'], $field['definition']); } } @@ -310,7 +310,7 @@ class Doctrine_Export_Mysql extends Doctrine_Export } $name = $this->conn->quoteIdentifier($name, true); - return $this->conn->exec("ALTER TABLE $name $query"); + return $this->conn->exec('ALTER TABLE ' . $name . ' ' . $query); } /** * create sequence diff --git a/lib/Doctrine/Export/Mysql/Exception.php b/lib/Doctrine/Export/Mysql/Exception.php deleted file mode 100644 index 419966d30..000000000 --- a/lib/Doctrine/Export/Mysql/Exception.php +++ /dev/null @@ -1,34 +0,0 @@ -. - */ -Doctrine::autoload('Doctrine_Export_Exception'); -/** - * Doctrine_Export_Mysql_Exception - * - * @package Doctrine - * @license http://www.opensource.org/licenses/lgpl-license.php LGPL - * @category Object Relational Mapping - * @link www.phpdoctrine.com - * @since 1.0 - * @version $Revision$ - * @author Konsta Vesterinen - */ -class Doctrine_Export_Mysql_Exception extends Doctrine_Export_Exception -{ } diff --git a/lib/Doctrine/Export/Oracle.php b/lib/Doctrine/Export/Oracle.php index 1a24b9841..ab1b97cb0 100644 --- a/lib/Doctrine/Export/Oracle.php +++ b/lib/Doctrine/Export/Oracle.php @@ -44,7 +44,7 @@ class Doctrine_Export_Oracle extends Doctrine_Export public function createDatabase($name) { if ( ! $this->conn->getAttribute(Doctrine::ATTR_EMULATE_DATABASE)) - throw new Doctrine_Export_Oracle_Exception('database creation is only supported if the "emulate_database" attribute is enabled'); + throw new Doctrine_Export_Exception('database creation is only supported if the "emulate_database" attribute is enabled'); $username = sprintf($this->conn->getAttribute(Doctrine::ATTR_DB_NAME_FORMAT), $name); $password = $this->conn->dsn['password'] ? $this->conn->dsn['password'] : $name; @@ -75,7 +75,7 @@ class Doctrine_Export_Oracle extends Doctrine_Export public function dropDatabase($name) { if ( ! $this->conn->getAttribute(Doctrine::ATTR_EMULATE_DATABASE)) - throw new Doctrine_Export_Oracle_Exception('database dropping is only supported if the + throw new Doctrine_Export_Exception('database dropping is only supported if the "emulate_database" option is enabled'); $username = sprintf($this->conn->getAttribute(Doctrine::ATTR_DB_NAME_FORMAT), $name); @@ -150,8 +150,8 @@ END; public function dropAutoincrement($table) { $table = strtoupper($table); - $trigger_name = $table . '_AI_PK'; - $trigger_name_quoted = $this->conn->getDbh()->quote($trigger_name); + $triggerName = $table . '_AI_PK'; + $trigger_name_quoted = $this->conn->quote($triggerName); $query = 'SELECT trigger_name FROM user_triggers'; $query.= ' WHERE trigger_name='.$trigger_name_quoted.' OR trigger_name='.strtoupper($trigger_name_quoted); $trigger = $this->conn->fetchOne($query); @@ -333,7 +333,7 @@ END; case 'rename': break; default: - throw new Doctrine_Export_Oracle_Exception('change type "'.$changeName.'" not yet supported'); + throw new Doctrine_Export_Exception('change type "'.$changeName.'" not yet supported'); } } diff --git a/lib/Doctrine/Export/Oracle/Exception.php b/lib/Doctrine/Export/Oracle/Exception.php deleted file mode 100644 index 715487ff8..000000000 --- a/lib/Doctrine/Export/Oracle/Exception.php +++ /dev/null @@ -1,34 +0,0 @@ -. - */ -Doctrine::autoload('Doctrine_Export_Exception'); -/** - * Doctrine_Export_Oracle_Exception - * - * @package Doctrine - * @license http://www.opensource.org/licenses/lgpl-license.php LGPL - * @category Object Relational Mapping - * @link www.phpdoctrine.com - * @since 1.0 - * @version $Revision$ - * @author Konsta Vesterinen - */ -class Doctrine_Export_Oracle_Exception extends Doctrine_Export_Exception -{ } diff --git a/lib/Doctrine/Export/Pgsql.php b/lib/Doctrine/Export/Pgsql.php index 193a0213b..89208df42 100644 --- a/lib/Doctrine/Export/Pgsql.php +++ b/lib/Doctrine/Export/Pgsql.php @@ -157,7 +157,7 @@ class Doctrine_Export_Pgsql extends Doctrine_Export case 'rename': break; default: - throw new Doctrine_Export_Pgsql_Exception('change type "'.$change_name.'\" not yet supported'); + throw new Doctrine_Export_Exception('change type "'.$change_name.'\" not yet supported'); } } @@ -187,7 +187,7 @@ class Doctrine_Export_Pgsql extends Doctrine_Export $server_info = $this->conn->getServerVersion(); if (is_array($server_info) && $server_info['major'] < 8) { - throw new Doctrine_Export_Pgsql_Exception('changing column type for "'.$change_name.'\" requires PostgreSQL 8.0 or above'); + throw new Doctrine_Export_Exception('changing column type for "'.$change_name.'\" requires PostgreSQL 8.0 or above'); } $query = "ALTER $field_name TYPE ".$this->conn->datatype->getTypeDeclaration($field['definition']); $this->conn->exec("ALTER TABLE $name $query"); diff --git a/lib/Doctrine/Export/Pgsql/Exception.php b/lib/Doctrine/Export/Pgsql/Exception.php deleted file mode 100644 index 8fa31afed..000000000 --- a/lib/Doctrine/Export/Pgsql/Exception.php +++ /dev/null @@ -1,33 +0,0 @@ -. - */ -Doctrine::autoload('Doctrine_Export_Exception'); -/** - * Doctrine_Export_Pgsql_Exception - * - * @package Doctrine - * @license http://www.opensource.org/licenses/lgpl-license.php LGPL - * @category Object Relational Mapping - * @link www.phpdoctrine.com - * @since 1.0 - * @version $Revision$ - * @author Konsta Vesterinen - */ -class Doctrine_Export_Pgsql_Exception extends Doctrine_Export_Exception { } diff --git a/lib/Doctrine/Export/Sqlite/Exception.php b/lib/Doctrine/Export/Sqlite/Exception.php deleted file mode 100644 index 64e372743..000000000 --- a/lib/Doctrine/Export/Sqlite/Exception.php +++ /dev/null @@ -1,34 +0,0 @@ -. - */ -Doctrine::autoload('Doctrine_Export_Exception'); -/** - * Doctrine_Export_Sqlite_Exception - * - * @package Doctrine - * @license http://www.opensource.org/licenses/lgpl-license.php LGPL - * @category Object Relational Mapping - * @link www.phpdoctrine.com - * @since 1.0 - * @version $Revision$ - * @author Konsta Vesterinen - */ -class Doctrine_Export_Sqlite_Exception extends Doctrine_Export_Exception -{ }