ZendDbSchema
Schema management for Zend Framework
Main Page
Related Pages
Namespaces
Classes
Files
File List
All
Classes
Namespaces
Functions
Pages
AbstractDefinition.php
1
<?php
29
abstract
class
ZendDbSchema_Db_Schema_Table_AbstractDefinition
30
extends
ZendDbSchema_Db_Schema_AbstractSchema
31
{
35
protected
$_table;
36
40
protected
$_toDelete;
41
47
abstract
protected
function
_getSchemaKey
();
48
56
public
function
__construct
($name,
ZendDbSchema_Db_Schema_Table
$table = null)
57
{
58
if
($table) {
59
$this->_table = $table;
60
}
61
parent::__construct
($name);
62
}
63
68
public
function
__clone
()
69
{
70
$this->_table = null;
71
}
72
79
public
function
__set
($name, $value)
80
{
81
if
(self::NAME_KEY == $name && $value) {
82
if
($this->_name != $value) {
83
$data = $this->
getTable
()->getCleanSchema();
84
if
(isset($data[$this->
_getSchemaKey
()][$value])) {
85
throw
new
ZendDbSchema_Db_Schema_Exception
(
"Definition with name '{$value}' already exists"
);
86
}
87
}
88
}
89
parent::__set
($name, $value);
90
}
91
97
protected
function
_getCleanSchema
()
98
{
99
$schema = array();
100
if
($this->
getTable
()) {
101
$data = $this->
getTable
()->getCleanSchema();
102
$name = $this->
getOriginName
();
103
104
if
(isset($data[$this->
_getSchemaKey
()][$name])) {
105
$schema = $data[$this->
_getSchemaKey
()][$name];
106
$schema[self::NAME_KEY] = $name;
107
}
108
}
109
return
$schema;
110
}
111
115
public
function
isDirty
($param = null)
116
{
117
if
(!$param && $this->
isDeleted
()) {
118
return
true
;
119
}
120
return
parent::isDirty
($param);
121
}
122
128
public
function
toSql
($alter =
false
)
129
{
130
if
(!$this->
getTable
()) {
131
throw
new
ZendDbSchema_Db_Schema_Exception
(
'Table not set'
);
132
}
133
134
if
($alter && $this->
isDeleted
()) {
135
return
$this->
getDropSql
();
136
}
137
return
parent::toSql
($alter);
138
}
139
145
public
function
getTable
()
146
{
147
return
$this->_table;
148
}
149
156
public
function
markDeleted
($toDelete =
true
)
157
{
158
if
(!$this->
isExist
()) {
159
throw
new
ZendDbSchema_Db_Schema_Exception
(
'Definition is not exist'
);
160
}
161
$this->_toDelete = (bool) $toDelete;
162
return
$this;
163
}
164
170
public
function
isDeleted
()
171
{
172
return
$this->_toDelete;
173
}
174
}
Db
Schema
Table
AbstractDefinition.php
Generated on Fri May 25 2012 13:46:45 for ZendDbSchema by
1.8.1