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
9b470a64
Commit
9b470a64
authored
May 18, 2007
by
zYne
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
--no commit message
--no commit message
parent
22753f19
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
14 additions
and
14 deletions
+14
-14
Pgsql.php
lib/Doctrine/Export/Pgsql.php
+14
-14
No files found.
lib/Doctrine/Export/Pgsql.php
View file @
9b470a64
...
...
@@ -143,7 +143,7 @@ class Doctrine_Export_Pgsql extends Doctrine_Export
* @param boolean $check indicates whether the function should just check if the DBMS driver
* can perform the requested table alterations if the value is true or
* actually perform them otherwise.
* @throws
PDO
Exception
* @throws
Doctrine_Connection_
Exception
* @return boolean
*/
public
function
alterTable
(
$name
,
array
$changes
,
$check
)
...
...
@@ -166,38 +166,38 @@ class Doctrine_Export_Pgsql extends Doctrine_Export
}
if
(
isset
(
$changes
[
'add'
])
&&
is_array
(
$changes
[
'add'
]))
{
foreach
(
$changes
[
'add'
]
as
$field
_n
ame
=>
$field
)
{
$query
=
'ADD '
.
$this
->
conn
->
getDeclaration
(
$field
[
'type'
],
$field
_n
ame
,
$field
);
foreach
(
$changes
[
'add'
]
as
$field
N
ame
=>
$field
)
{
$query
=
'ADD '
.
$this
->
conn
->
getDeclaration
(
$field
[
'type'
],
$field
N
ame
,
$field
);
$this
->
conn
->
exec
(
'ALTER TABLE '
.
$name
.
' '
.
$query
);
}
}
if
(
isset
(
$changes
[
'remove'
])
&&
is_array
(
$changes
[
'remove'
]))
{
foreach
(
$changes
[
'remove'
]
as
$field
_n
ame
=>
$field
)
{
$field
_name
=
$this
->
conn
->
quoteIdentifier
(
$field_n
ame
,
true
);
$query
=
'DROP '
.
$field
_n
ame
;
foreach
(
$changes
[
'remove'
]
as
$field
N
ame
=>
$field
)
{
$field
Name
=
$this
->
conn
->
quoteIdentifier
(
$fieldN
ame
,
true
);
$query
=
'DROP '
.
$field
N
ame
;
$this
->
conn
->
exec
(
'ALTER TABLE '
.
$name
.
' '
.
$query
);
}
}
if
(
isset
(
$changes
[
'change'
])
&&
is_array
(
$changes
[
'change'
]))
{
foreach
(
$changes
[
'change'
]
as
$field
_n
ame
=>
$field
)
{
$fieldName
=
$this
->
conn
->
quoteIdentifier
(
$field
_n
ame
,
true
);
foreach
(
$changes
[
'change'
]
as
$field
N
ame
=>
$field
)
{
$fieldName
=
$this
->
conn
->
quoteIdentifier
(
$field
N
ame
,
true
);
if
(
isset
(
$field
[
'type'
]))
{
$server
_i
nfo
=
$this
->
conn
->
getServerVersion
();
$server
I
nfo
=
$this
->
conn
->
getServerVersion
();
if
(
is_array
(
$server
_info
)
&&
$server_i
nfo
[
'major'
]
<
8
)
{
if
(
is_array
(
$server
Info
)
&&
$serverI
nfo
[
'major'
]
<
8
)
{
throw
new
Doctrine_Export_Exception
(
'changing column type for "'
.
$field
[
'type'
]
.
'\" requires PostgreSQL 8.0 or above'
);
}
$query
=
"ALTER
$field_name
TYPE "
.
$this
->
conn
->
datatype
->
getTypeDeclaration
(
$field
[
'definition'
]);
$query
=
'ALTER '
.
$fieldName
.
' TYPE '
.
$this
->
conn
->
datatype
->
getTypeDeclaration
(
$field
[
'definition'
]);
$this
->
conn
->
exec
(
'ALTER TABLE '
.
$name
.
' '
.
$query
);;
}
if
(
array_key_exists
(
'default'
,
$field
))
{
$query
=
"ALTER
$field_name
SET DEFAULT "
.
$this
->
conn
->
quote
(
$field
[
'definition'
][
'default'
],
$field
[
'definition'
][
'type'
]);
$query
=
'ALTER '
.
$fieldName
.
' SET DEFAULT '
.
$this
->
conn
->
quote
(
$field
[
'definition'
][
'default'
],
$field
[
'definition'
][
'type'
]);
$this
->
conn
->
exec
(
'ALTER TABLE '
.
$name
.
' '
.
$query
);
}
if
(
!
empty
(
$field
[
'notnull'
]))
{
$query
=
"ALTER
$field_name
"
.
(
$field
[
'definition'
][
'notnull'
]
?
"SET"
:
"DROP"
)
.
' NOT NULL'
;
$query
=
'ALTER '
.
$fieldName
.
' '
.
(
$field
[
'definition'
][
'notnull'
]
?
'SET'
:
'DROP'
)
.
' NOT NULL'
;
$this
->
conn
->
exec
(
'ALTER TABLE '
.
$name
.
' '
.
$query
);
}
}
...
...
@@ -205,7 +205,7 @@ class Doctrine_Export_Pgsql extends Doctrine_Export
if
(
isset
(
$changes
[
'rename'
])
&&
is_array
(
$changes
[
'rename'
]))
{
foreach
(
$changes
[
'rename'
]
as
$fieldName
=>
$field
)
{
$field
_n
ame
=
$this
->
conn
->
quoteIdentifier
(
$fieldName
,
true
);
$field
N
ame
=
$this
->
conn
->
quoteIdentifier
(
$fieldName
,
true
);
$this
->
conn
->
exec
(
'ALTER TABLE '
.
$name
.
' RENAME COLUMN '
.
$fieldName
.
' TO '
.
$this
->
conn
->
quoteIdentifier
(
$field
[
'name'
],
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