Db2 Php Entity Base.class.php
this-oldInstance {
this-oldInstance=clone this;
A-152
this-oldInstance-notifyPristine; }
} return true if this instance has been modified since the last notifyPristine call
return bool public function isChanged {
return null==this-oldInstance; }
return array with the field id as index and the new value as value of values which have been changed since the last notifyPristine call
return array public function getFieldsValuesChanged {
changed=array; if this-isChanged {
return changed; }
old=this-oldInstance-toArray; new=this-toArray;
foreach old as fieldId=value { if new[fieldId]==value {
changed[fieldId]=new[fieldId]; }
} return changed;
} return array with the field ids of values which have been changed since the last notifyPristine call
return array public function getFieldsChanged {
return array_keysthis-getFieldsValuesChanged; }
set this instance into pristine state public function notifyPristine {
this-oldInstance=null; }
get object as string return string
public function __toString { s=null;
foreach this-toHash as fieldName=value { s.=fieldName . : . value . \n;
} return s;
} create hash from dom node
param DOMNode node param array fieldNames
return array protected static function domNodeToHashnode, fieldNames, defaultValues=null, fieldTypes=null {
result=array; foreach node-childNodes as child {
if child instanceof DOMElement in_arraychild-localName, fieldNames {
A-153
if 0==strlenchild-nodeValue null==defaultValues { result[child-localName]=defaultValues[array_searchchild-
localName, fieldNames]; } else {
result[child-localName]=child-nodeValue; }
} }
return result; }
create DOM document from passed hash param array hash
param string rootNodeName return DOMDocument
protected static function hashToDomDocumenthash, rootNodeName { doc=new DOMDocument;
root=doc-createElementrootNodeName; foreach hash as fieldName=value {
if null==value { fElem=doc-createElementfieldName;
fElem-appendChilddoc-createTextNodevalue; root-appendChildfElem;
} }
doc-appendChildroot; return doc;
} }
?