This commit is contained in:
parent
c8ac51e864
commit
0bf5bf839c
@ -41,6 +41,17 @@ class Doctrine_Export extends Doctrine_Connection_Module
|
|||||||
* @return void
|
* @return void
|
||||||
*/
|
*/
|
||||||
public function dropDatabase($database)
|
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.');
|
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
|
* @return void
|
||||||
*/
|
*/
|
||||||
public function createDatabase($database)
|
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.');
|
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);
|
$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'])) {
|
if (isset($options['primary']) && ! empty($options['primary'])) {
|
||||||
$queryFields .= ', PRIMARY KEY(' . implode(', ', array_values($options['primary'])) . ')';
|
$queryFields .= ', PRIMARY KEY(' . implode(', ', array_values($options['primary'])) . ')';
|
||||||
|
@ -37,25 +37,21 @@ class Doctrine_Export_Mysql extends Doctrine_Export
|
|||||||
* create a new database
|
* create a new database
|
||||||
*
|
*
|
||||||
* @param string $name name of the database that should be created
|
* @param string $name name of the database that should be created
|
||||||
* @throws PDOException
|
* @return string
|
||||||
* @return void
|
|
||||||
*/
|
*/
|
||||||
public function createDatabase($name)
|
public function createDatabaseSql($name)
|
||||||
{
|
{
|
||||||
$query = 'CREATE DATABASE ' . $this->conn->quoteIdentifier($name, true);
|
return 'CREATE DATABASE ' . $this->conn->quoteIdentifier($name, true);
|
||||||
$result = $this->conn->exec($query);
|
|
||||||
}
|
}
|
||||||
/**
|
/**
|
||||||
* drop an existing database
|
* drop an existing database
|
||||||
*
|
*
|
||||||
* @param string $name name of the database that should be dropped
|
* @param string $name name of the database that should be dropped
|
||||||
* @throws PDOException
|
* @return string
|
||||||
* @access public
|
|
||||||
*/
|
*/
|
||||||
public function dropDatabase($name)
|
public function dropDatabaseSql($name)
|
||||||
{
|
{
|
||||||
$query = 'DROP DATABASE ' . $this->conn->quoteIdentifier($name);
|
return 'DROP DATABASE ' . $this->conn->quoteIdentifier($name);
|
||||||
$this->conn->exec($query);
|
|
||||||
}
|
}
|
||||||
/**
|
/**
|
||||||
* create a new table
|
* 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'])) {
|
if (isset($options['primary']) && ! empty($options['primary'])) {
|
||||||
$queryFields .= ', PRIMARY KEY(' . implode(', ', array_values($options['primary'])) . ')';
|
$queryFields .= ', PRIMARY KEY(' . implode(', ', array_values($options['primary'])) . ')';
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
$name = $this->conn->quoteIdentifier($name, true);
|
$name = $this->conn->quoteIdentifier($name, true);
|
||||||
$query = 'CREATE TABLE ' . $name . ' (' . $queryFields . ')';
|
$query = 'CREATE TABLE ' . $name . ' (' . $queryFields . ')';
|
||||||
|
|
||||||
@ -612,10 +600,10 @@ class Doctrine_Export_Mysql extends Doctrine_Export
|
|||||||
$query .= ' MATCH ' . $definition['match'];
|
$query .= ' MATCH ' . $definition['match'];
|
||||||
}
|
}
|
||||||
if (!empty($definition['onUpdate'])) {
|
if (!empty($definition['onUpdate'])) {
|
||||||
$query .= ' ON UPDATE ' . $this->getForeignKeyRefentialAction($definition['onUpdate']);
|
$query .= ' ON UPDATE ' . $this->getForeignKeyReferentialAction($definition['onUpdate']);
|
||||||
}
|
}
|
||||||
if (!empty($definition['onDelete'])) {
|
if (!empty($definition['onDelete'])) {
|
||||||
$query .= ' ON DELETE ' . $this->getForeignKeyRefentialAction($definition['onDelete']);
|
$query .= ' ON DELETE ' . $this->getForeignKeyReferentialAction($definition['onDelete']);
|
||||||
}
|
}
|
||||||
return $query;
|
return $query;
|
||||||
}
|
}
|
||||||
|
@ -201,11 +201,13 @@ class Doctrine_Export_Sqlite extends Doctrine_Export
|
|||||||
$query = 'CREATE TABLE ' . $name . ' (' . $queryFields . ')';
|
$query = 'CREATE TABLE ' . $name . ' (' . $queryFields . ')';
|
||||||
|
|
||||||
try {
|
try {
|
||||||
|
/**
|
||||||
if ( ! empty($fk)) {
|
if ( ! empty($fk)) {
|
||||||
$this->conn->beginTransaction();
|
$this->conn->beginTransaction();
|
||||||
}
|
}
|
||||||
|
*/
|
||||||
$ret = $this->conn->exec($query);
|
$ret = $this->conn->exec($query);
|
||||||
|
/**
|
||||||
if ( ! empty($fk)) {
|
if ( ! empty($fk)) {
|
||||||
foreach ($fk as $definition) {
|
foreach ($fk as $definition) {
|
||||||
|
|
||||||
@ -226,6 +228,7 @@ class Doctrine_Export_Sqlite extends Doctrine_Export
|
|||||||
|
|
||||||
$this->conn->commit();
|
$this->conn->commit();
|
||||||
}
|
}
|
||||||
|
*/
|
||||||
} catch(Doctrine_Exception $e) {
|
} catch(Doctrine_Exception $e) {
|
||||||
|
|
||||||
$this->conn->rollback();
|
$this->conn->rollback();
|
||||||
|
Loading…
x
Reference in New Issue
Block a user