/**
* Returns an element from the $_data associative .gif' />.
*/
function _getData($attributeName) {
$this->_data[$attributeName];
}
/**
* If the supplied value passes validation, this
* s the value in the $_data associative .gif' />.
*/
function _Data($attributeName, $value) {
($this->validateAttribute($attributeName, $value)) {
($value != $this->_data[$attributeName]) {
$this->_data[$attributeName] = $value;
$this->_modiedKeys = $attributeName;
$this->didChange;
} {
// the value is identical to the current _disibledevent=> (method_exists($this, $methodName)) {
$this->$methodName($value);
} {
true;
}
}
function didChange {
// noty the objectStore that this record changed
}
}
?>
现在我们拥有了个抽象超级类(Record),我们可以将User类里面大量代码转移出来而让这个User子类来关注User特殊项目如存取和验证思路方法你可能已经注意到在我们这个纪录类(Record)没有任何=t_tag _disibledevent=>SQL代码这并不是疏忽或者遗漏!对象存储类(ObjectStore)(隐藏在第 2部分)将负责所有和数据库交互还有我们超级类Record例子化这样使我们Record类更加瘦小而又有效率而这对于评价我们处理大量对象效率时候是个重要原因
如果你有兴趣看看这篇文章基于完整代码(不会出现如文中出现所有语法) TAG: 数据库 对象
最新评论