ZendDbSchema
Schema management for Zend Framework
Main Page
Related Pages
Namespaces
Classes
Files
File List
All
Classes
Namespaces
Functions
Pages
Database.php
1
<?php
29
class
ZendDbSchema_Db_Schema_Generator_Pgsql_Database
30
implements
ZendDbSchema_Db_Schema_Generator_Database
31
{
38
public
function
createDatabase
(
ZendDbSchema_Db_Schema_Database
$schema)
39
{
40
$props = array();
41
42
if
($schema->owner) {
43
$props[] =
"OWNER {$schema->owner}"
;
44
}
45
if
($schema->
getCharset
()) {
46
$props[] =
"ENCODING "
. $schema->
getCharset
();
47
}
48
49
if
($schema->template) {
50
$props[] =
"TEMPLATE {$schema->template}"
;
51
}
52
53
if
($schema->tablespace) {
54
$props[] =
"TABLESPACE {$schema->tablespace}"
;
55
}
56
57
if
($schema->connlimit) {
58
$props[] =
"CONNECTION LIMIT {$schema->connlimit}"
;
59
}
60
61
$name = $schema->
getName
();
62
$query = array();
63
$query[] =
"DROP DATABASE IF EXISTS {$name}"
;
64
$query[] =
"CREATE DATABASE {$name} "
. join(
' '
, $props);
65
66
return
join(
';'
. PHP_EOL, $query);
67
}
68
75
public
function
alterDatabase
(
ZendDbSchema_Db_Schema_Database
$schema)
76
{
77
if
(!$schema->
isExist
()) {
78
return
null;
79
}
80
81
$props = array();
82
if
($schema->template) {
83
$props[] =
"ENCODING {$schema->template}"
;
84
}
85
86
if
($schema->tablespace) {
87
$props[] =
"TABLESPACE {$schema->tablespace}"
;
88
}
89
90
if
($schema->connlimit) {
91
$props[] =
"CONNECTION LIMIT {$schema->connlimit}"
;
92
}
93
94
$name = $schema->
getName
();
95
96
$query =
''
;
97
if
($schema->
isDirty
(
'charset'
)) {
98
$charset = $schema->
getCharset
();
99
$query =
"ALTER DATABASE {$name} DEFAULT CHARACTER SET {$charset}"
;
100
}
101
return
$query;
102
}
103
110
public
function
dropDatabase
(
ZendDbSchema_Db_Schema_Database
$schema)
111
{
112
if
(!$schema->
isExist
()) {
113
return
null;
114
}
115
return
"DROP DATABASE IF EXISTS {$schema->getOriginName()}"
;
116
}
117
}
Db
Schema
Generator
Pgsql
Database.php
Generated on Fri May 25 2012 13:46:45 for ZendDbSchema by
1.8.1