1
0
mirror of synced 2024-12-13 22:56:04 +03:00

updated export drivers + removed unnecessary exceptions

This commit is contained in:
zYne 2007-01-25 22:36:43 +00:00
parent b6575631b3
commit 9e6ea208f2
12 changed files with 29 additions and 265 deletions

View File

@ -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);
}
}

View File

@ -1,34 +0,0 @@
<?php
/*
* $Id$
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
* This software consists of voluntary contributions made by many individuals
* and is licensed under the LGPL. For more information, see
* <http://www.phpdoctrine.com>.
*/
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 <kvesteri@cc.hut.fi>
*/
class Doctrine_Export_Firebird_Exception extends Doctrine_Export_Exception
{ }

View File

@ -1,34 +0,0 @@
<?php
/*
* $Id$
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
* This software consists of voluntary contributions made by many individuals
* and is licensed under the LGPL. For more information, see
* <http://www.phpdoctrine.com>.
*/
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 <kvesteri@cc.hut.fi>
*/
class Doctrine_Export_Informix_Exception extends Doctrine_Export_Exception
{ }

View File

@ -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');
}
}

View File

@ -1,34 +0,0 @@
<?php
/*
* $Id$
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
* This software consists of voluntary contributions made by many individuals
* and is licensed under the LGPL. For more information, see
* <http://www.phpdoctrine.com>.
*/
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 <kvesteri@cc.hut.fi>
*/
class Doctrine_Export_Mssql_Exception extends Doctrine_Export_Exception
{ }

View File

@ -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

View File

@ -1,34 +0,0 @@
<?php
/*
* $Id$
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
* This software consists of voluntary contributions made by many individuals
* and is licensed under the LGPL. For more information, see
* <http://www.phpdoctrine.com>.
*/
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 <kvesteri@cc.hut.fi>
*/
class Doctrine_Export_Mysql_Exception extends Doctrine_Export_Exception
{ }

View File

@ -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');
}
}

View File

@ -1,34 +0,0 @@
<?php
/*
* $Id$
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
* This software consists of voluntary contributions made by many individuals
* and is licensed under the LGPL. For more information, see
* <http://www.phpdoctrine.com>.
*/
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 <kvesteri@cc.hut.fi>
*/
class Doctrine_Export_Oracle_Exception extends Doctrine_Export_Exception
{ }

View File

@ -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");

View File

@ -1,33 +0,0 @@
<?php
/*
* $Id$
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
* This software consists of voluntary contributions made by many individuals
* and is licensed under the LGPL. For more information, see
* <http://www.phpdoctrine.com>.
*/
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 <kvesteri@cc.hut.fi>
*/
class Doctrine_Export_Pgsql_Exception extends Doctrine_Export_Exception { }

View File

@ -1,34 +0,0 @@
<?php
/*
* $Id$
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
* This software consists of voluntary contributions made by many individuals
* and is licensed under the LGPL. For more information, see
* <http://www.phpdoctrine.com>.
*/
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 <kvesteri@cc.hut.fi>
*/
class Doctrine_Export_Sqlite_Exception extends Doctrine_Export_Exception
{ }