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
b8353881
Commit
b8353881
authored
Jun 17, 2007
by
zYne
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fixed sequence handling
parent
642d44d3
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
28 additions
and
7 deletions
+28
-7
Mssql.php
lib/Doctrine/Sequence/Mssql.php
+26
-5
Mysql.php
lib/Doctrine/Sequence/Mysql.php
+2
-2
No files found.
lib/Doctrine/Sequence/Mssql.php
View file @
b8353881
...
...
@@ -40,13 +40,13 @@ class Doctrine_Sequence_Mssql extends Doctrine_Sequence
*
* @return integer next id in the given sequence
*/
public
function
nextId
(
$seqName
,
$on
d
emand
=
true
)
public
function
nextId
(
$seqName
,
$on
D
emand
=
true
)
{
$sequenceName
=
$this
->
conn
->
quoteIdentifier
(
$this
->
formatter
->
getSequenceName
(
$seqName
),
true
);
$seqcolName
=
$this
->
conn
->
quoteIdentifier
(
$this
->
getAttribute
(
Doctrine
::
ATTR_SEQCOL_NAME
),
true
);
$sequenceName
=
$this
->
conn
->
quoteIdentifier
(
$this
->
conn
->
formatter
->
getSequenceName
(
$seqName
),
true
);
$seqcolName
=
$this
->
conn
->
quoteIdentifier
(
$this
->
conn
->
getAttribute
(
Doctrine
::
ATTR_SEQCOL_NAME
),
true
);
if
(
$this
->
_
checkSequence
(
$sequenceName
))
{
if
(
$this
->
checkSequence
(
$sequenceName
))
{
$query
=
'SET IDENTITY_INSERT '
.
$sequenceName
.
' ON '
.
'INSERT INTO '
.
$sequenceName
.
' ('
.
$seqcolName
.
') VALUES (0)'
;
}
else
{
...
...
@@ -57,7 +57,7 @@ class Doctrine_Sequence_Mssql extends Doctrine_Sequence
$this
->
conn
->
exec
(
$query
);
}
catch
(
Doctrine_Connection_Exception
$e
)
{
if
(
$on
demand
&&
!
$this
->
_checkSequence
(
$sequenceName
)
)
{
if
(
$on
Demand
&&
$e
->
getPortableCode
()
==
Doctrine
::
ERR_NOSUCHTABLE
)
{
// Since we are creating the sequence on demand
// we know the first id = 1 so initialize the
// sequence at 2
...
...
@@ -69,6 +69,7 @@ class Doctrine_Sequence_Mssql extends Doctrine_Sequence
// First ID of a newly created sequence is 1
return
1
;
}
throw
$e
;
}
$value
=
$this
->
lastInsertId
(
$sequenceName
);
...
...
@@ -85,6 +86,26 @@ class Doctrine_Sequence_Mssql extends Doctrine_Sequence
}
return
$value
;
}
/**
* Checks if there's a sequence that exists.
*
* @param string $seqName The sequence name to verify.
* @return bool $tableExists The value if the table exists or not
* @access private
*/
public
function
checkSequence
(
$seqName
)
{
$query
=
'SELECT COUNT(1) FROM '
.
$seqName
;
try
{
$this
->
conn
->
execute
(
$query
);
}
catch
(
Doctrine_Connection_Exception
$e
)
{
if
(
$e
->
getPortableCode
()
==
Doctrine
::
ERR_NOSUCHTABLE
)
{
return
false
;
}
}
return
true
;
}
/**
* Returns the autoincrement ID if supported or $id or fetches the current
* ID in a sequence called: $table.(empty($field) ? '' : '_'.$field)
...
...
lib/Doctrine/Sequence/Mysql.php
View file @
b8353881
...
...
@@ -40,7 +40,7 @@ class Doctrine_Sequence_Mysql extends Doctrine_Sequence
*
* @return integer next id in the given sequence
*/
public
function
nextId
(
$seqName
,
$on
d
emand
=
true
)
public
function
nextId
(
$seqName
,
$on
D
emand
=
true
)
{
$sequenceName
=
$this
->
conn
->
quoteIdentifier
(
$this
->
conn
->
formatter
->
getSequenceName
(
$seqName
),
true
);
$seqcolName
=
$this
->
conn
->
quoteIdentifier
(
$this
->
conn
->
getAttribute
(
Doctrine
::
ATTR_SEQCOL_NAME
),
true
);
...
...
@@ -51,7 +51,7 @@ class Doctrine_Sequence_Mysql extends Doctrine_Sequence
$this
->
conn
->
exec
(
$query
);
}
catch
(
Doctrine_Connection_Exception
$e
)
{
if
(
$on
d
emand
&&
$e
->
getPortableCode
()
==
Doctrine
::
ERR_NOSUCHTABLE
)
{
if
(
$on
D
emand
&&
$e
->
getPortableCode
()
==
Doctrine
::
ERR_NOSUCHTABLE
)
{
// Since we are creating the sequence on demand
// we know the first id = 1 so initialize the
// sequence at 2
...
...
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