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_Mysql_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->collate) {
43
$props[] =
"COLLATE "
. $schema->collate;
44
}
45
if
($schema->
getCharset
()) {
46
$props[] =
"DEFAULT CHARACTER SET "
. $schema->
getCharset
();
47
}
48
49
$name = $schema->
getName
();
50
51
$query = array();
52
$query[] =
"DROP DATABASE IF EXISTS `{$name}`"
;
53
$query[] =
"CREATE DATABASE `{$name}` "
. join(
' '
, $props);
54
55
return
join(
';'
. PHP_EOL, $query);
56
}
57
64
public
function
alterDatabase
(
ZendDbSchema_Db_Schema_Database
$schema)
65
{
66
if
(!$schema->
isExist
()) {
67
return
null;
68
}
69
70
$props = array();
71
if
($schema->
isDirty
(
'collate'
)) {
72
$props[] =
"COLLATE "
. $schema->collate;
73
}
74
if
($schema->
getCharset
()) {
75
$props[] =
"DEFAULT CHARACTER SET "
. $schema->
getCharset
();
76
}
77
78
$query =
''
;
79
if
(!empty($props)) {
80
$name = $schema->
getName
();
81
$query =
"ALTER DATABASE `{$name}` "
. join(
' '
, $props);
82
}
83
return
$query;
84
}
85
92
public
function
dropDatabase
(
ZendDbSchema_Db_Schema_Database
$schema)
93
{
94
if
(!$schema->
isExist
()) {
95
return
null;
96
}
97
return
"DROP DATABASE IF EXISTS {$schema->getOriginName()}"
;
98
}
99
}
Db
Schema
Generator
Mysql
Database.php
Generated on Fri May 25 2012 13:46:45 for ZendDbSchema by
1.8.1