From d1a1697a5f3827fede16e28be32808189c75e269 Mon Sep 17 00:00:00 2001 From: zYne Date: Wed, 13 Jun 2007 22:31:15 +0000 Subject: [PATCH] E_STRICT fixes --- lib/Doctrine/Export.php | 44 ++++++++++++++++++++++++++++---- lib/Doctrine/Export/Firebird.php | 15 +++++++---- lib/Doctrine/Export/Mssql.php | 22 ++++++++++------ lib/Doctrine/Export/Oracle.php | 23 ++++++++++------- lib/Doctrine/Export/Pgsql.php | 20 ++++++++++----- 5 files changed, 91 insertions(+), 33 deletions(-) diff --git a/lib/Doctrine/Export.php b/lib/Doctrine/Export.php index f9a9b5f76..3862fcea5 100644 --- a/lib/Doctrine/Export.php +++ b/lib/Doctrine/Export.php @@ -65,9 +65,21 @@ class Doctrine_Export extends Doctrine_Connection_Module * @return void */ public function dropIndex($table, $name) + { + return $this->conn->exec($this->dropIndexSql($table, $name)); + } + + /** + * dropIndexSql + * + * @param string $table name of table that should be used in method + * @param string $name name of the index to be dropped + * @return string SQL that is used for dropping an index + */ + public function dropIndexSql($table, $name) { $name = $this->conn->quoteIdentifier($this->conn->formatter->getIndexName($name)); - return $this->conn->exec('DROP INDEX ' . $name); + return 'DROP INDEX ' . $name; } /** * drop existing constraint @@ -84,13 +96,27 @@ class Doctrine_Export extends Doctrine_Connection_Module return $this->conn->exec('ALTER TABLE ' . $table . ' DROP CONSTRAINT ' . $name); } /** + * dropSequenceSql * drop existing sequence * (this method is implemented by the drivers) * - * @param string $seq_name name of the sequence to be dropped + * @throws Doctrine_Connection_Exception if something fails at database level + * @param string $sequenceName name of the sequence to be dropped * @return void */ - public function dropSequence($name) + public function dropSequence($sequenceName) + { + $this->conn->exec($this->dropSequenceSql($sequenceName)); + } + /** + * dropSequenceSql + * drop existing sequence + * + * @throws Doctrine_Connection_Exception if something fails at database level + * @param string $sequenceName name of the sequence to be dropped + * @return void + */ + public function dropSequenceSql($sequenceName) { throw new Doctrine_Export_Exception('Drop sequence not supported by this driver.'); } @@ -184,18 +210,26 @@ class Doctrine_Export extends Doctrine_Connection_Module /** * create sequence * + * @throws Doctrine_Connection_Exception if something fails at database level * @param string $seqName name of the sequence to be created * @param string $start start value of the sequence; default is 1 + * @param array $options An associative array of table options: + * array( + * 'comment' => 'Foo', + * 'charset' => 'utf8', + * 'collate' => 'utf8_unicode_ci', + * ); * @return void */ - public function createSequence($seqName, $start = 1) + public function createSequence($seqName, $start = 1, array $options = array()) { - return $this->conn->execute($this->createSequenceSql($seqName, $start = 1)); + return $this->conn->execute($this->createSequenceSql($seqName, $start = 1, $options)); } /** * return RDBMS specific create sequence statement * (this method is implemented by the drivers) * + * @throws Doctrine_Connection_Exception if something fails at database level * @param string $seqName name of the sequence to be created * @param string $start start value of the sequence; default is 1 * @param array $options An associative array of table options: diff --git a/lib/Doctrine/Export/Firebird.php b/lib/Doctrine/Export/Firebird.php index d16cf7b75..5e01aea9a 100644 --- a/lib/Doctrine/Export/Firebird.php +++ b/lib/Doctrine/Export/Firebird.php @@ -498,14 +498,19 @@ class Doctrine_Export_Firebird extends Doctrine_Export * * @param string $seqName name of the sequence to be created * @param string $start start value of the sequence; default is 1 - * @return void + * @param array $options An associative array of table options: + * array( + * 'comment' => 'Foo', + * 'charset' => 'utf8', + * 'collate' => 'utf8_unicode_ci', + * ); + * @return string */ - public function createSequence($seqName, $start = 1) + public function createSequence($seqName, $start = 1, array $options = array()) { $sequenceName = $this->conn->formatter->getSequenceName($seqName); $this->conn->exec('CREATE GENERATOR ' . $sequenceName); - $this->conn->exec('SET GENERATOR ' . $sequenceName . ' TO ' . ($start-1)); $this->dropSequence($seqName); @@ -516,12 +521,12 @@ class Doctrine_Export_Firebird extends Doctrine_Export * @param string $seqName name of the sequence to be dropped * @return void */ - public function dropSequence($seqName) + public function dropSequenceSql($seqName) { $sequenceName = $this->conn->formatter->getSequenceName($seqName); $sequenceName = $this->conn->quote($sequenceName); $query = "DELETE FROM RDB\$GENERATORS WHERE UPPER(RDB\$GENERATOR_NAME)=" . $sequenceName; - return $this->conn->exec($query); + return $query; } } diff --git a/lib/Doctrine/Export/Mssql.php b/lib/Doctrine/Export/Mssql.php index 120408881..68ba5b796 100644 --- a/lib/Doctrine/Export/Mssql.php +++ b/lib/Doctrine/Export/Mssql.php @@ -208,16 +208,22 @@ class Doctrine_Export_Mssql extends Doctrine_Export /** * create sequence * - * @param string $seqName name of the sequence to be created - * @param string $start start value of the sequence; default is 1 - * @return void + * @param string $seqName name of the sequence to be created + * @param string $start start value of the sequence; default is 1 + * @param array $options An associative array of table options: + * array( + * 'comment' => 'Foo', + * 'charset' => 'utf8', + * 'collate' => 'utf8_unicode_ci', + * ); + * @return string */ - public function createSequence($seqName, $start = 1) + public function createSequence($seqName, $start = 1, array $options = array()) { $sequenceName = $this->conn->quoteIdentifier($this->conn->getSequenceName($seqName), true); $seqcolName = $this->conn->quoteIdentifier($this->conn->options['seqcol_name'], true); - $query = 'CREATE TABLE ' . $sequenceName . ' (' . $seqcolName . - ' INT PRIMARY KEY CLUSTERED IDENTITY(' . $start . ',1) NOT NULL)'; + $query = 'CREATE TABLE ' . $sequenceName . ' (' . $seqcolName . + ' INT PRIMARY KEY CLUSTERED IDENTITY(' . $start . ', 1) NOT NULL)'; $res = $this->conn->exec($query); @@ -240,9 +246,9 @@ class Doctrine_Export_Mssql extends Doctrine_Export * @param string $seqName name of the sequence to be dropped * @return void */ - public function dropSequence($seqName) + public function dropSequenceSql($seqName) { $sequenceName = $this->conn->quoteIdentifier($this->conn->getSequenceName($seqName), true); - return $this->conn->exec('DROP TABLE ' . $sequenceName); + return 'DROP TABLE ' . $sequenceName; } } diff --git a/lib/Doctrine/Export/Oracle.php b/lib/Doctrine/Export/Oracle.php index e8d0ce73a..d66a91408 100644 --- a/lib/Doctrine/Export/Oracle.php +++ b/lib/Doctrine/Export/Oracle.php @@ -432,28 +432,33 @@ END; /** * create sequence * - * @param object $this->conn database object that is extended by this class * @param string $seqName name of the sequence to be created * @param string $start start value of the sequence; default is 1 - * @return void + * @param array $options An associative array of table options: + * array( + * 'comment' => 'Foo', + * 'charset' => 'utf8', + * 'collate' => 'utf8_unicode_ci', + * ); + * @return string */ - public function createSequence($seqName, $start = 1) + public function createSequenceSql($seqName, $start = 1, array $options = array()) { $sequenceName = $this->conn->quoteIdentifier($this->conn->formatter->getSequenceName($seqName), true); - $query = 'CREATE SEQUENCE ' . $sequenceName . ' START WITH ' . $start . ' INCREMENT BY 1 NOCACHE'; - $query.= ($start < 1 ? ' MINVALUE ' . $start : ''); - return $this->conn->exec($query); + $query = 'CREATE SEQUENCE ' . $sequenceName . ' START WITH ' . $start . ' INCREMENT BY 1 NOCACHE'; + $query .= ($start < 1 ? ' MINVALUE ' . $start : ''); + return $query; } /** * drop existing sequence * * @param object $this->conn database object that is extended by this class * @param string $seqName name of the sequence to be dropped - * @return void + * @return string */ - public function dropSequence($seqName) + public function dropSequenceSql($seqName) { $sequenceName = $this->conn->quoteIdentifier($this->conn->formatter->getSequenceName($seqName), true); - return $this->conn->exec('DROP SEQUENCE ' . $sequenceName); + return 'DROP SEQUENCE ' . $sequenceName; } } diff --git a/lib/Doctrine/Export/Pgsql.php b/lib/Doctrine/Export/Pgsql.php index 1403331c6..336f3bfe3 100644 --- a/lib/Doctrine/Export/Pgsql.php +++ b/lib/Doctrine/Export/Pgsql.php @@ -251,12 +251,20 @@ class Doctrine_Export_Pgsql extends Doctrine_Export } } /** - * create sequence + * return RDBMS specific create sequence statement * - * @param string $sequenceName name of the sequence to be created - * @param string $start start value of the sequence; default is 1 + * @throws Doctrine_Connection_Exception if something fails at database level + * @param string $seqName name of the sequence to be created + * @param string $start start value of the sequence; default is 1 + * @param array $options An associative array of table options: + * array( + * 'comment' => 'Foo', + * 'charset' => 'utf8', + * 'collate' => 'utf8_unicode_ci', + * ); + * @return string */ - public function createSequence($sequenceName, $start = 1) + public function createSequenceSql($sequenceName, $start = 1, array $options = array()) { $sequenceName = $this->conn->quoteIdentifier($this->conn->formatter->getSequenceName($sequenceName), true); return $this->conn->exec('CREATE SEQUENCE ' . $sequenceName . ' INCREMENT 1' . @@ -267,10 +275,10 @@ class Doctrine_Export_Pgsql extends Doctrine_Export * * @param string $sequenceName name of the sequence to be dropped */ - public function dropSequence($sequenceName) + public function dropSequenceSql($sequenceName) { $sequenceName = $this->conn->quoteIdentifier($this->conn->formatter->getSequenceName($sequenceName), true); - return $this->conn->exec('DROP SEQUENCE ' . $sequenceName); + return 'DROP SEQUENCE ' . $sequenceName; } }