Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
D
doctrine-dbal
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Tomáš Trávníček
doctrine-dbal
Commits
0bf5bf83
Commit
0bf5bf83
authored
Jun 14, 2007
by
zYne
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
--no commit message
--no commit message
parent
c8ac51e8
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
35 additions
and
28 deletions
+35
-28
Export.php
lib/Doctrine/Export.php
+23
-7
Mysql.php
lib/Doctrine/Export/Mysql.php
+8
-20
Sqlite.php
lib/Doctrine/Export/Sqlite.php
+4
-1
No files found.
lib/Doctrine/Export.php
View file @
0bf5bf83
...
...
@@ -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'
]))
.
')'
;
...
...
lib/Doctrine/Export/Mysql.php
View file @
0bf5bf83
...
...
@@ -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
createDatabase
Sql
(
$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
dropDatabase
Sql
(
$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
->
getForeignKeyRefe
re
ntialAction
(
$definition
[
'onUpdate'
]);
}
if
(
!
empty
(
$definition
[
'onDelete'
]))
{
$query
.=
' ON DELETE '
.
$this
->
getForeignKeyRefentialAction
(
$definition
[
'onDelete'
]);
$query
.=
' ON DELETE '
.
$this
->
getForeignKeyRefe
re
ntialAction
(
$definition
[
'onDelete'
]);
}
return
$query
;
}
...
...
lib/Doctrine/Export/Sqlite.php
View file @
0bf5bf83
...
...
@@ -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
();
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment