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
9d8cb481
Commit
9d8cb481
authored
May 18, 2007
by
zYne
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
--no commit message
--no commit message
parent
4b09d95d
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
25 additions
and
25 deletions
+25
-25
Mssql.php
lib/Doctrine/Export/Mssql.php
+25
-25
No files found.
lib/Doctrine/Export/Mssql.php
View file @
9d8cb481
...
...
@@ -20,7 +20,7 @@
*/
Doctrine
::
autoload
(
'Doctrine_Export'
);
/**
* Doctrine_Export_
Oracle
* Doctrine_Export_
Mssql
*
* @package Doctrine
* @author Konsta Vesterinen <kvesteri@cc.hut.fi>
...
...
@@ -60,7 +60,7 @@ class Doctrine_Export_Mssql extends Doctrine_Export
public
function
dropDatabase
(
$name
)
{
$name
=
$this
->
conn
->
quoteIdentifier
(
$name
,
true
);
return
$this
->
conn
->
standaloneQuery
(
"DROP DATABASE
$name
"
,
null
,
true
);
return
$this
->
conn
->
standaloneQuery
(
'DROP DATABASE '
.
$name
,
null
,
true
);
}
/**
* alter an existing table
...
...
@@ -152,8 +152,8 @@ class Doctrine_Export_Mssql extends Doctrine_Export
*/
public
function
alterTable
(
$name
,
$changes
,
$check
)
{
foreach
(
$changes
as
$change
_n
ame
=>
$change
)
{
switch
(
$change
_n
ame
)
{
foreach
(
$changes
as
$change
N
ame
=>
$change
)
{
switch
(
$change
N
ame
)
{
case
'add'
:
break
;
case
'remove'
:
...
...
@@ -162,50 +162,50 @@ class Doctrine_Export_Mssql extends Doctrine_Export
case
'rename'
:
case
'change'
:
default
:
throw
new
Doctrine_Export_Exception
(
'alterTable: change type "'
.
$change
_n
ame
.
'" not yet supported'
);
throw
new
Doctrine_Export_Exception
(
'alterTable: change type "'
.
$change
N
ame
.
'" not yet supported'
);
}
}
$query
=
''
;
if
(
!
empty
(
$changes
[
'add'
])
&&
is_array
(
$changes
[
'add'
]))
{
foreach
(
$changes
[
'add'
]
as
$field
_n
ame
=>
$field
)
{
if
(
!
empty
(
$changes
[
'add'
])
&&
is_array
(
$changes
[
'add'
]))
{
foreach
(
$changes
[
'add'
]
as
$field
N
ame
=>
$field
)
{
if
(
$query
)
{
$query
.=
', '
;
$query
.=
', '
;
}
$query
.=
'ADD '
.
$this
->
conn
->
getDeclaration
(
$field
[
'type'
],
$field_n
ame
,
$field
);
$query
.=
'ADD '
.
$this
->
conn
->
getDeclaration
(
$field
[
'type'
],
$fieldN
ame
,
$field
);
}
}
if
(
!
empty
(
$changes
[
'remove'
])
&&
is_array
(
$changes
[
'remove'
]))
{
foreach
(
$changes
[
'remove'
]
as
$field
_n
ame
=>
$field
)
{
if
(
!
empty
(
$changes
[
'remove'
])
&&
is_array
(
$changes
[
'remove'
]))
{
foreach
(
$changes
[
'remove'
]
as
$field
N
ame
=>
$field
)
{
if
(
$query
)
{
$query
.=
', '
;
$query
.=
', '
;
}
$field_name
=
$this
->
conn
->
quoteIdentifier
(
$field
_n
ame
,
true
);
$query
.=
'DROP COLUMN '
.
$field_n
ame
;
$field_name
=
$this
->
conn
->
quoteIdentifier
(
$field
N
ame
,
true
);
$query
.=
'DROP COLUMN '
.
$fieldN
ame
;
}
}
if
(
!
$query
)
{
if
(
!
$query
)
{
return
false
;
}
$name
=
$this
->
conn
->
quoteIdentifier
(
$name
,
true
);
return
$this
->
conn
->
exec
(
"ALTER TABLE
$name
$query
"
);
return
$this
->
conn
->
exec
(
'ALTER TABLE '
.
$name
.
' '
.
$query
);
}
/**
* create sequence
*
* @param string $seq
_name
name of the sequence to be created
* @param string $seq
Name
name of the sequence to be created
* @param string $start start value of the sequence; default is 1
* @return void
*/
public
function
createSequence
(
$seq
_n
ame
,
$start
=
1
)
public
function
createSequence
(
$seq
N
ame
,
$start
=
1
)
{
$sequence
_name
=
$this
->
conn
->
quoteIdentifier
(
$this
->
conn
->
getSequenceName
(
$seq_n
ame
),
true
);
$seqcol
_n
ame
=
$this
->
conn
->
quoteIdentifier
(
$this
->
conn
->
options
[
'seqcol_name'
],
true
);
$query
=
"CREATE TABLE
$sequence_name
(
$seqcol_name
"
.
"INT PRIMARY KEY CLUSTERED IDENTITY(
$start
,1) NOT NULL)"
;
$sequence
Name
=
$this
->
conn
->
quoteIdentifier
(
$this
->
conn
->
getSequenceName
(
$seqN
ame
),
true
);
$seqcol
N
ame
=
$this
->
conn
->
quoteIdentifier
(
$this
->
conn
->
options
[
'seqcol_name'
],
true
);
$query
=
'CREATE TABLE '
.
$sequenceName
.
' ('
.
$seqcolName
.
' INT PRIMARY KEY CLUSTERED IDENTITY('
.
$start
.
',1) NOT NULL)'
;
$res
=
$this
->
conn
->
exec
(
$query
);
...
...
@@ -214,11 +214,11 @@ class Doctrine_Export_Mssql extends Doctrine_Export
}
try
{
$query
=
'SET IDENTITY_INSERT
$sequence_name
ON '
.
'INSERT INTO
$sequence_name ('
.
$seqcol_n
ame
.
') VALUES ( '
.
$start
.
')'
;
$query
=
'SET IDENTITY_INSERT
'
.
$sequenceName
.
'
ON '
.
'INSERT INTO
'
.
$sequenceName
.
' ('
.
$seqcolN
ame
.
') VALUES ( '
.
$start
.
')'
;
$res
=
$this
->
conn
->
exec
(
$query
);
}
catch
(
Exception
$e
)
{
$result
=
$this
->
conn
->
exec
(
"DROP TABLE
$sequence_name
"
);
$result
=
$this
->
conn
->
exec
(
'DROP TABLE '
.
$sequenceName
);
}
return
true
;
}
...
...
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