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
ec6fc688
Commit
ec6fc688
authored
Feb 10, 2007
by
zYne
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
--no commit message
--no commit message
parent
653b42c2
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
21 additions
and
22 deletions
+21
-22
Pgsql.php
lib/Doctrine/Export/Pgsql.php
+21
-22
No files found.
lib/Doctrine/Export/Pgsql.php
View file @
ec6fc688
...
...
@@ -148,8 +148,8 @@ class Doctrine_Export_Pgsql 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'
:
case
'remove'
:
case
'change'
:
...
...
@@ -157,7 +157,7 @@ class Doctrine_Export_Pgsql extends Doctrine_Export
case
'rename'
:
break
;
default
:
throw
new
Doctrine_Export_Exception
(
'change type "'
.
$change_name
.
'\" not yet supported'
);
throw
new
Doctrine_Export_Exception
(
'change type "'
.
$changeName
.
'\" not yet supported'
);
}
}
...
...
@@ -165,56 +165,55 @@ class Doctrine_Export_Pgsql extends Doctrine_Export
return
true
;
}
if
(
!
empty
(
$changes
[
'add'
])
&&
is_array
(
$changes
[
'add'
]))
{
if
(
isset
(
$changes
[
'add'
])
&&
is_array
(
$changes
[
'add'
]))
{
foreach
(
$changes
[
'add'
]
as
$field_name
=>
$field
)
{
$query
=
'ADD '
.
$this
->
conn
->
getDeclaration
(
$field
[
'type'
],
$field_name
,
$field
);
$this
->
conn
->
exec
(
"ALTER TABLE
$name
$query
"
);
$this
->
conn
->
exec
(
'ALTER TABLE '
.
$name
.
' '
.
$query
);
}
}
if
(
!
empty
(
$changes
[
'remove'
])
&&
is_array
(
$changes
[
'remove'
]))
{
if
(
isset
(
$changes
[
'remove'
])
&&
is_array
(
$changes
[
'remove'
]))
{
foreach
(
$changes
[
'remove'
]
as
$field_name
=>
$field
)
{
$field_name
=
$this
->
conn
->
quoteIdentifier
(
$field_name
,
true
);
$query
=
'DROP '
.
$field_name
;
$this
->
conn
->
exec
(
"ALTER TABLE
$name
$query
"
);
$this
->
conn
->
exec
(
'ALTER TABLE '
.
$name
.
' '
.
$query
);
}
}
if
(
!
empty
(
$changes
[
'change'
])
&&
is_array
(
$changes
[
'change'
]))
{
if
(
isset
(
$changes
[
'change'
])
&&
is_array
(
$changes
[
'change'
]))
{
foreach
(
$changes
[
'change'
]
as
$field_name
=>
$field
)
{
$field
_n
ame
=
$this
->
conn
->
quoteIdentifier
(
$field_name
,
true
);
if
(
!
empty
(
$field
[
'type'
]))
{
$field
N
ame
=
$this
->
conn
->
quoteIdentifier
(
$field_name
,
true
);
if
(
isset
(
$field
[
'type'
]))
{
$server_info
=
$this
->
conn
->
getServerVersion
();
if
(
is_array
(
$server_info
)
&&
$server_info
[
'major'
]
<
8
)
{
throw
new
Doctrine_Export_Exception
(
'changing column type for "'
.
$
change_name
.
'\" requires PostgreSQL 8.0 or above'
);
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'
]);
$this
->
conn
->
exec
(
"ALTER TABLE
$name
$query
"
)
;
$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'
]);
$this
->
conn
->
exec
(
"ALTER TABLE
$name
$query
"
);
$this
->
conn
->
exec
(
'ALTER TABLE '
.
$name
.
' '
.
$query
);
}
if
(
!
empty
(
$field
[
'notnull'
]))
{
$query
=
"ALTER
$field_name
"
.
(
$field
[
'definition'
][
'notnull'
]
?
"SET"
:
"DROP"
)
.
' NOT NULL'
;
$this
->
conn
->
exec
(
"ALTER TABLE
$name
$query
"
);
$this
->
conn
->
exec
(
'ALTER TABLE '
.
$name
.
' '
.
$query
);
}
}
}
if
(
!
empty
(
$changes
[
'rename'
])
&&
is_array
(
$changes
[
'rename'
]))
{
foreach
(
$changes
[
'rename'
]
as
$field
_n
ame
=>
$field
)
{
$field_name
=
$this
->
conn
->
quoteIdentifier
(
$field
_n
ame
,
true
);
$this
->
conn
->
exec
(
"ALTER TABLE
$name
RENAME COLUMN
$field_name
TO "
.
$this
->
conn
->
quoteIdentifier
(
$field
[
'name'
],
true
));
if
(
isset
(
$changes
[
'rename'
])
&&
is_array
(
$changes
[
'rename'
]))
{
foreach
(
$changes
[
'rename'
]
as
$field
N
ame
=>
$field
)
{
$field_name
=
$this
->
conn
->
quoteIdentifier
(
$field
N
ame
,
true
);
$this
->
conn
->
exec
(
'ALTER TABLE '
.
$name
.
' RENAME COLUMN '
.
$fieldName
.
' TO '
.
$this
->
conn
->
quoteIdentifier
(
$field
[
'name'
],
true
));
}
}
$name
=
$this
->
conn
->
quoteIdentifier
(
$name
,
true
);
if
(
!
empty
(
$changes
[
'name'
]))
{
$change
_n
ame
=
$this
->
conn
->
quoteIdentifier
(
$changes
[
'name'
],
true
);
$this
->
conn
->
exec
(
"ALTER TABLE
$name
RENAME TO "
.
$change_n
ame
);
if
(
isset
(
$changes
[
'name'
]))
{
$change
N
ame
=
$this
->
conn
->
quoteIdentifier
(
$changes
[
'name'
],
true
);
$this
->
conn
->
exec
(
'ALTER TABLE '
.
$name
.
' RENAME TO '
.
$changeN
ame
);
}
}
}
...
...
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