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
ac8492d2
Commit
ac8492d2
authored
May 30, 2009
by
romanb
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[2.0] DBAL code cleanups.
parent
9586b748
Changes
5
Expand all
Show whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
87 additions
and
174 deletions
+87
-174
AbstractSchemaManager.php
lib/Doctrine/DBAL/Schema/AbstractSchemaManager.php
+40
-96
MsSqlSchemaManager.php
lib/Doctrine/DBAL/Schema/MsSqlSchemaManager.php
+2
-12
MySqlSchemaManager.php
lib/Doctrine/DBAL/Schema/MySqlSchemaManager.php
+27
-22
OracleSchemaManager.php
lib/Doctrine/DBAL/Schema/OracleSchemaManager.php
+5
-36
SqliteSchemaManager.php
lib/Doctrine/DBAL/Schema/SqliteSchemaManager.php
+13
-8
No files found.
lib/Doctrine/DBAL/Schema/AbstractSchemaManager.php
View file @
ac8492d2
This diff is collapsed.
Click to expand it.
lib/Doctrine/DBAL/Schema/MsSqlSchemaManager.php
View file @
ac8492d2
...
@@ -195,19 +195,9 @@ class MsSqlSchemaManager extends AbstractSchemaManager
...
@@ -195,19 +195,9 @@ class MsSqlSchemaManager extends AbstractSchemaManager
}
}
/**
/**
* create sequence
* {@inheritdoc}
*
* @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
,
array
$options
=
array
()
)
public
function
createSequence
(
$seqName
,
$start
=
1
,
$allocationSize
=
1
)
{
{
$sequenceName
=
$this
->
conn
->
quoteIdentifier
(
$this
->
conn
->
getSequenceName
(
$seqName
),
true
);
$sequenceName
=
$this
->
conn
->
quoteIdentifier
(
$this
->
conn
->
getSequenceName
(
$seqName
),
true
);
$seqcolName
=
$this
->
conn
->
quoteIdentifier
(
$this
->
conn
->
options
[
'seqcol_name'
],
true
);
$seqcolName
=
$this
->
conn
->
quoteIdentifier
(
$this
->
conn
->
options
[
'seqcol_name'
],
true
);
...
...
lib/Doctrine/DBAL/Schema/MySqlSchemaManager.php
View file @
ac8492d2
...
@@ -294,11 +294,15 @@ class MySqlSchemaManager extends AbstractSchemaManager
...
@@ -294,11 +294,15 @@ class MySqlSchemaManager extends AbstractSchemaManager
return
$foreignKey
;
return
$foreignKey
;
}
}
public
function
createSequence
(
$sequenceName
,
$start
=
1
,
array
$options
=
array
())
/**
* {@inheritdoc}
*/
public
function
createSequence
(
$sequenceName
,
$start
=
1
,
$allocationSize
=
1
)
{
{
$sequenceName
=
$this
->
_conn
->
quoteIdentifier
(
$this
->
_conn
->
getSequenceName
(
$sequenceName
),
tru
e
);
$sequenceName
=
$this
->
_conn
->
quoteIdentifier
(
$sequenceNam
e
);
$seq
colName
=
$this
->
_conn
->
quoteIdentifier
(
$this
->
_conn
->
getAttribute
(
Doctrine
::
ATTR_SEQCOL_NAME
),
true
)
;
$seq
ColumnName
=
'mysql_sequence'
;
/* No support for options yet. Might add 4th options parameter later
$optionsStrings = array();
$optionsStrings = array();
if (isset($options['comment']) && ! empty($options['comment'])) {
if (isset($options['comment']) && ! empty($options['comment'])) {
...
@@ -322,16 +326,17 @@ class MySqlSchemaManager extends AbstractSchemaManager
...
@@ -322,16 +326,17 @@ class MySqlSchemaManager extends AbstractSchemaManager
}
}
if ($type) {
if ($type) {
$optionsStrings[] = 'ENGINE = ' . $type;
$optionsStrings[] = 'ENGINE = ' . $type;
}
}
*/
try
{
try
{
$query
=
'CREATE TABLE '
.
$sequenceName
$query
=
'CREATE TABLE '
.
$sequenceName
.
' ('
.
$seqcolName
.
' INT NOT NULL AUTO_INCREMENT, PRIMARY KEY ('
.
' ('
.
$seqcolName
.
' INT NOT NULL AUTO_INCREMENT, PRIMARY KEY ('
.
$seqcolName
.
'))'
;
.
$seqcolName
.
'))'
;
if
(
!
empty
(
$options_strings
))
{
/*
if (!empty($options_strings)) {
$query .= ' '.implode(' ', $options_strings);
$query .= ' '.implode(' ', $options_strings);
}
}*/
$query
.=
' ENGINE = INNODB'
;
$res
=
$this
->
_conn
->
exec
(
$query
);
$res
=
$this
->
_conn
->
exec
(
$query
);
}
catch
(
Doctrine\DBAL\ConnectionException
$e
)
{
}
catch
(
Doctrine\DBAL\ConnectionException
$e
)
{
...
@@ -339,7 +344,7 @@ class MySqlSchemaManager extends AbstractSchemaManager
...
@@ -339,7 +344,7 @@ class MySqlSchemaManager extends AbstractSchemaManager
}
}
if
(
$start
==
1
)
{
if
(
$start
==
1
)
{
return
true
;
return
;
}
}
$query
=
'INSERT INTO '
.
$sequenceName
$query
=
'INSERT INTO '
.
$sequenceName
...
@@ -350,7 +355,7 @@ class MySqlSchemaManager extends AbstractSchemaManager
...
@@ -350,7 +355,7 @@ class MySqlSchemaManager extends AbstractSchemaManager
// Handle error
// Handle error
try
{
try
{
$res
=
$this
->
_conn
->
exec
(
'DROP TABLE '
.
$sequenceName
);
$res
=
$this
->
_conn
->
exec
(
'DROP TABLE '
.
$sequenceName
);
}
catch
(
Doctrine\DBAL\Connection
Exception
$e
)
{
}
catch
(
\
Exception
$e
)
{
throw
\Doctrine\Common\DoctrineException
::
updateMe
(
'could not drop inconsistent sequence table'
);
throw
\Doctrine\Common\DoctrineException
::
updateMe
(
'could not drop inconsistent sequence table'
);
}
}
...
...
lib/Doctrine/DBAL/Schema/OracleSchemaManager.php
View file @
ac8492d2
...
@@ -239,53 +239,22 @@ class OracleSchemaManager extends AbstractSchemaManager
...
@@ -239,53 +239,22 @@ class OracleSchemaManager extends AbstractSchemaManager
{
{
try
{
try
{
$this
->
dropAutoincrement
(
$name
);
$this
->
dropAutoincrement
(
$name
);
}
catch
(
\Exception
$e
)
{}
}
catch
(
\Exception
$e
)
{
//FIXME: Exception silencing ;'-(
return
parent
::
dropTable
(
$name
);
}
}
/**
return
parent
::
dropTable
(
$name
);
* create sequence
*
* @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
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
$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 string
*/
public
function
dropSequenceSql
(
$seqName
)
{
$sequenceName
=
$this
->
_conn
->
quoteIdentifier
(
$this
->
_conn
->
formatter
->
getSequenceName
(
$seqName
),
true
);
return
'DROP SEQUENCE '
.
$sequenceName
;
}
}
/**
/**
*
lists all database sequences
*
Lists all sequences.
*
*
* @param string|null $database
* @param string|null $database
* @return array
* @return array
*/
*/
public
function
listSequences
(
$database
=
null
)
public
function
listSequences
(
$database
=
null
)
{
{
//FIXME: $database not used. Remove?
$query
=
"SELECT sequence_name FROM sys.user_sequences"
;
$query
=
"SELECT sequence_name FROM sys.user_sequences"
;
$tableNames
=
$this
->
_conn
->
fetchColumn
(
$query
);
$tableNames
=
$this
->
_conn
->
fetchColumn
(
$query
);
...
...
lib/Doctrine/DBAL/Schema/SqliteSchemaManager.php
View file @
ac8492d2
...
@@ -33,21 +33,26 @@ namespace Doctrine\DBAL\Schema;
...
@@ -33,21 +33,26 @@ namespace Doctrine\DBAL\Schema;
*/
*/
class
SqliteSchemaManager
extends
AbstractSchemaManager
class
SqliteSchemaManager
extends
AbstractSchemaManager
{
{
public
function
dropDatabase
(
$database
=
null
)
/**
* {@inheritdoc}
*
* @override
*/
public
function
dropDatabase
(
$database
)
{
{
if
(
is_null
(
$database
))
{
$database
=
$this
->
_conn
->
getDatabase
();
}
if
(
file_exists
(
$database
))
{
if
(
file_exists
(
$database
))
{
unlink
(
$database
);
unlink
(
$database
);
}
}
}
}
public
function
createDatabase
(
$database
=
null
)
/**
* {@inheritdoc}
*
* @override
*/
public
function
createDatabase
(
$database
)
{
{
if
(
is_null
(
$database
))
{
// FIXME: $database parameter not used
$database
=
$this
->
_conn
->
getDatabase
();
}
// TODO: Can we do this better?
// TODO: Can we do this better?
$this
->
_conn
->
close
();
$this
->
_conn
->
close
();
$this
->
_conn
->
connect
();
$this
->
_conn
->
connect
();
...
...
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