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
Hide 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
}
/**
* 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
* {@inheritdoc}
*/
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
);
$seqcolName
=
$this
->
conn
->
quoteIdentifier
(
$this
->
conn
->
options
[
'seqcol_name'
],
true
);
...
...
lib/Doctrine/DBAL/Schema/MySqlSchemaManager.php
View file @
ac8492d2
...
...
@@ -293,14 +293,18 @@ class MySqlSchemaManager extends AbstractSchemaManager
);
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
);
$seq
colName
=
$this
->
_conn
->
quoteIdentifier
(
$this
->
_conn
->
getAttribute
(
Doctrine
::
ATTR_SEQCOL_NAME
),
true
)
;
$sequenceName
=
$this
->
_conn
->
quoteIdentifier
(
$sequenceNam
e
);
$seq
ColumnName
=
'mysql_sequence'
;
/* No support for options yet. Might add 4th options parameter later
$optionsStrings = array();
if (isset($options['comment']) && ! empty($options['comment'])) {
$optionsStrings['comment'] = 'COMMENT = ' . $this->_conn->quote($options['comment'], 'string');
}
...
...
@@ -312,7 +316,7 @@ class MySqlSchemaManager extends AbstractSchemaManager
$optionsStrings['collate'] .= ' COLLATE ' . $options['collate'];
}
}
$type = false;
if (isset($options['type'])) {
...
...
@@ -322,38 +326,39 @@ class MySqlSchemaManager extends AbstractSchemaManager
}
if ($type) {
$optionsStrings[] = 'ENGINE = ' . $type;
}
}
*/
try
{
$query
=
'CREATE TABLE '
.
$sequenceName
.
' ('
.
$seqcolName
.
' INT NOT NULL AUTO_INCREMENT, PRIMARY KEY ('
.
$seqcolName
.
'))'
;
if
(
!
empty
(
$options_strings
))
{
/*
if (!empty($options_strings)) {
$query .= ' '.implode(' ', $options_strings);
}
}*/
$query
.=
' ENGINE = INNODB'
;
$res
=
$this
->
_conn
->
exec
(
$query
);
$res
=
$this
->
_conn
->
exec
(
$query
);
}
catch
(
Doctrine\DBAL\ConnectionException
$e
)
{
throw
\Doctrine\Common\DoctrineException
::
updateMe
(
'could not create sequence table'
);
}
if
(
$start
==
1
)
{
return
true
;
}
return
;
}
$query
=
'INSERT INTO '
.
$sequenceName
$query
=
'INSERT INTO '
.
$sequenceName
.
' ('
.
$seqcolName
.
') VALUES ('
.
(
$start
-
1
)
.
')'
;
$res
=
$this
->
_conn
->
exec
(
$query
);
// Handle error
try
{
$res
=
$this
->
_conn
->
exec
(
'DROP TABLE '
.
$sequenceName
);
}
catch
(
Doctrine\DBAL\ConnectionException
$e
)
{
throw
\Doctrine\Common\DoctrineException
::
updateMe
(
'could not drop inconsistent sequence table'
);
}
$res
=
$this
->
_conn
->
exec
(
$query
);
return
$res
;
// Handle error
try
{
$res
=
$this
->
_conn
->
exec
(
'DROP TABLE '
.
$sequenceName
);
}
catch
(
\Exception
$e
)
{
throw
\Doctrine\Common\DoctrineException
::
updateMe
(
'could not drop inconsistent sequence table'
);
}
return
$res
;
}
}
\ No newline at end of file
lib/Doctrine/DBAL/Schema/OracleSchemaManager.php
View file @
ac8492d2
...
...
@@ -239,53 +239,22 @@ class OracleSchemaManager extends AbstractSchemaManager
{
try
{
$this
->
dropAutoincrement
(
$name
);
}
catch
(
\Exception
$e
)
{}
}
catch
(
\Exception
$e
)
{
//FIXME: Exception silencing ;'-(
}
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
* @return array
*/
public
function
listSequences
(
$database
=
null
)
{
//FIXME: $database not used. Remove?
$query
=
"SELECT sequence_name FROM sys.user_sequences"
;
$tableNames
=
$this
->
_conn
->
fetchColumn
(
$query
);
...
...
lib/Doctrine/DBAL/Schema/SqliteSchemaManager.php
View file @
ac8492d2
...
...
@@ -33,21 +33,26 @@ namespace Doctrine\DBAL\Schema;
*/
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
))
{
unlink
(
$database
);
}
}
public
function
createDatabase
(
$database
=
null
)
/**
* {@inheritdoc}
*
* @override
*/
public
function
createDatabase
(
$database
)
{
if
(
is_null
(
$database
))
{
$database
=
$this
->
_conn
->
getDatabase
();
}
// FIXME: $database parameter not used
// TODO: Can we do this better?
$this
->
_conn
->
close
();
$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