1
0
mirror of synced 2025-01-18 22:41:43 +03:00
This commit is contained in:
zYne 2007-06-14 20:29:33 +00:00
parent c8ac51e864
commit 0bf5bf839c
3 changed files with 35 additions and 28 deletions

View File

@ -41,6 +41,17 @@ class Doctrine_Export extends Doctrine_Connection_Module
* @return void
*/
public function dropDatabase($database)
{
$this->conn->execute($this->dropDatabaseSql($database));
}
/**
* drop an existing database
* (this method is implemented by the drivers)
*
* @param string $name name of the database that should be dropped
* @return void
*/
public function dropDatabaseSql($database)
{
throw new Doctrine_Export_Exception('Drop database not supported by this driver.');
}
@ -128,6 +139,17 @@ class Doctrine_Export extends Doctrine_Connection_Module
* @return void
*/
public function createDatabase($database)
{
$this->conn->execute($this->createDatabaseSql($database));
}
/**
* create a new database
* (this method is implemented by the drivers)
*
* @param string $name name of the database that should be created
* @return string
*/
public function createDatabaseSql($database)
{
throw new Doctrine_Export_Exception('Create database not supported by this driver.');
}
@ -170,13 +192,7 @@ class Doctrine_Export extends Doctrine_Connection_Module
}
$queryFields = $this->getFieldDeclarationList($fields);
/**
if (isset($options['foreignKeys']) && ! empty($options['foreignKeys'])) {
foreach($options['foreignKeys'] as $definition) {
$queryFields .= ', ' . $this->getForeignKeyDeclaration($definition);
}
}
*/
if (isset($options['primary']) && ! empty($options['primary'])) {
$queryFields .= ', PRIMARY KEY(' . implode(', ', array_values($options['primary'])) . ')';

View File

@ -37,25 +37,21 @@ class Doctrine_Export_Mysql extends Doctrine_Export
* create a new database
*
* @param string $name name of the database that should be created
* @throws PDOException
* @return void
* @return string
*/
public function createDatabase($name)
public function createDatabaseSql($name)
{
$query = 'CREATE DATABASE ' . $this->conn->quoteIdentifier($name, true);
$result = $this->conn->exec($query);
return 'CREATE DATABASE ' . $this->conn->quoteIdentifier($name, true);
}
/**
* drop an existing database
*
* @param string $name name of the database that should be dropped
* @throws PDOException
* @access public
* @return string
*/
public function dropDatabase($name)
public function dropDatabaseSql($name)
{
$query = 'DROP DATABASE ' . $this->conn->quoteIdentifier($name);
$this->conn->exec($query);
return 'DROP DATABASE ' . $this->conn->quoteIdentifier($name);
}
/**
* create a new table
@ -147,18 +143,10 @@ class Doctrine_Export_Mysql extends Doctrine_Export
}
}
if (isset($options['foreignKeys']) && ! empty($options['foreignKeys'])) {
foreach($options['foreignKeys'] as $definition) {
$queryFields .= ', ' . $this->getForeignKeyDeclaration($definition);
}
}
if (isset($options['primary']) && ! empty($options['primary'])) {
$queryFields .= ', PRIMARY KEY(' . implode(', ', array_values($options['primary'])) . ')';
}
$name = $this->conn->quoteIdentifier($name, true);
$query = 'CREATE TABLE ' . $name . ' (' . $queryFields . ')';
@ -612,10 +600,10 @@ class Doctrine_Export_Mysql extends Doctrine_Export
$query .= ' MATCH ' . $definition['match'];
}
if (!empty($definition['onUpdate'])) {
$query .= ' ON UPDATE ' . $this->getForeignKeyRefentialAction($definition['onUpdate']);
$query .= ' ON UPDATE ' . $this->getForeignKeyReferentialAction($definition['onUpdate']);
}
if (!empty($definition['onDelete'])) {
$query .= ' ON DELETE ' . $this->getForeignKeyRefentialAction($definition['onDelete']);
$query .= ' ON DELETE ' . $this->getForeignKeyReferentialAction($definition['onDelete']);
}
return $query;
}

View File

@ -201,11 +201,13 @@ class Doctrine_Export_Sqlite extends Doctrine_Export
$query = 'CREATE TABLE ' . $name . ' (' . $queryFields . ')';
try {
/**
if ( ! empty($fk)) {
$this->conn->beginTransaction();
}
*/
$ret = $this->conn->exec($query);
/**
if ( ! empty($fk)) {
foreach ($fk as $definition) {
@ -226,6 +228,7 @@ class Doctrine_Export_Sqlite extends Doctrine_Export
$this->conn->commit();
}
*/
} catch(Doctrine_Exception $e) {
$this->conn->rollback();