| 3 |
## $Id$ |
## $Id$ |
| 4 |
## ------------------------------------------------------------------------------------- |
## ------------------------------------------------------------------------------------- |
| 5 |
## $Log$ |
## $Log$ |
| 6 |
|
## Revision 1.4 2002/12/12 02:46:31 joko |
| 7 |
|
## + state (session) gets flushed when data was successfully loaded from remote side |
| 8 |
|
## + fixed _loadBackend |
| 9 |
|
## + fixed flushState |
| 10 |
|
## |
| 11 |
|
## Revision 1.3 2002/12/06 04:12:54 joko |
| 12 |
|
## + replaced 'xyzCache' through 'xyzProxy' |
| 13 |
|
## + function store(...) |
| 14 |
|
## |
| 15 |
## Revision 1.2 2002/12/05 21:44:09 joko |
## Revision 1.2 2002/12/05 21:44:09 joko |
| 16 |
## + debugging |
## + debugging |
| 17 |
## |
## |
| 81 |
if ($objectId) { |
if ($objectId) { |
| 82 |
$this->objectId = $objectId; |
$this->objectId = $objectId; |
| 83 |
$this->load(); |
$this->load(); |
| 84 |
//$this->_saveCache(); |
//$this->_saveProxy(); |
| 85 |
} |
} |
| 86 |
} |
} |
| 87 |
|
|
| 88 |
function load() { |
function load() { |
| 89 |
if (!$this->_loadState()) { |
if (!$this->_loadState()) { |
| 90 |
if (!$this->_loadCache()) { |
if (!$this->_loadProxy()) { |
| 91 |
$this->_loadBackend(); |
$this->_loadBackend(); |
| 92 |
} |
} |
| 93 |
} |
} |
| 106 |
|
|
| 107 |
function flush() { |
function flush() { |
| 108 |
$this->flushState(); |
$this->flushState(); |
| 109 |
$this->flushCache(); |
$this->flushProxy(); |
| 110 |
} |
} |
| 111 |
|
|
| 112 |
function _commit() { |
function _commit() { |
| 113 |
$this->_saveBackend($this->attributes); |
$this->_saveBackend($this->attributes); |
| 114 |
$this->flushState(); |
$this->flushState(); |
| 115 |
$this->flushCache(); |
$this->flushProxy(); |
| 116 |
} |
} |
| 117 |
|
|
| 118 |
|
|
| 121 |
function _create() { |
function _create() { |
| 122 |
$this->_createBackend($this->attributes); |
$this->_createBackend($this->attributes); |
| 123 |
$this->flushState(); |
$this->flushState(); |
| 124 |
$this->flushCache(); |
$this->flushProxy(); |
| 125 |
} |
} |
| 126 |
*/ |
*/ |
| 127 |
|
|
| 137 |
$this->attributes = $data; |
$this->attributes = $data; |
| 138 |
} |
} |
| 139 |
|
|
| 140 |
function flushCache() { |
function flushProxy() { |
| 141 |
connectdb(); |
connectdb(); |
| 142 |
$sql = "DELETE FROM f_proxy WHERE oid='$this->objectId'"; |
$sql = "DELETE FROM f_proxy WHERE oid='$this->objectId'"; |
| 143 |
send_sql($sql); |
send_sql($sql); |
| 146 |
function flushState() { |
function flushState() { |
| 147 |
global $proxy; |
global $proxy; |
| 148 |
unset($proxy[$this->objectId]); |
unset($proxy[$this->objectId]); |
| 149 |
|
$this->meta[decoded] = 0; |
| 150 |
} |
} |
| 151 |
|
|
| 152 |
function _loadState() { |
function _loadState() { |
| 168 |
// TODO: throw exception-message back to user if operation fails |
// TODO: throw exception-message back to user if operation fails |
| 169 |
} |
} |
| 170 |
|
|
| 171 |
function _loadCache() { |
function _loadProxy() { |
| 172 |
logp(get_class($this) . "->_loadCache()", LOG_DEBUG); |
logp(get_class($this) . "->_loadProxy()", LOG_DEBUG); |
| 173 |
connectdb(); |
connectdb(); |
| 174 |
$sql = "SELECT payload FROM f_proxy WHERE oid='$this->objectId'"; |
$sql = "SELECT payload FROM f_proxy WHERE oid='$this->objectId'"; |
| 175 |
if ($res = send_sql($sql)) { |
if ($res = send_sql($sql)) { |
| 182 |
} |
} |
| 183 |
} |
} |
| 184 |
|
|
| 185 |
function _saveCache() { |
// TODO: use PEAR here |
| 186 |
logp(get_class($this) . "->_saveCache()", LOG_DEBUG); |
function _saveProxy() { |
| 187 |
|
logp(get_class($this) . "->_saveProxy()", LOG_DEBUG); |
| 188 |
connectdb(); |
connectdb(); |
| 189 |
if ($this->payload) { |
if ($this->payload) { |
| 190 |
//$sql = "INSERT INTO f_proxy SET payload='$this->payload' WHERE oid='$this->objectId'"; |
//$sql = "INSERT INTO f_proxy SET payload='$this->payload' WHERE oid='$this->objectId'"; |
| 208 |
print dumpVar($result); |
print dumpVar($result); |
| 209 |
} |
} |
| 210 |
$this->payload = serialize($result); |
$this->payload = serialize($result); |
| 211 |
$this->_saveCache(); |
$this->_saveProxy(); |
| 212 |
|
//print "oid: $this->objectId<br>"; |
| 213 |
|
$this->flushState(); |
| 214 |
} |
} |
| 215 |
} |
} |
| 216 |
|
|
| 229 |
$this->meta[decoded] = 1; |
$this->meta[decoded] = 1; |
| 230 |
} |
} |
| 231 |
} |
} |
| 232 |
|
|
| 233 |
|
function store($struct) { |
| 234 |
|
$this->payload = serialize($struct); |
| 235 |
|
$this->_saveProxy(); |
| 236 |
|
} |
| 237 |
|
|
| 238 |
} |
} |
| 239 |
|
|