3 |
## $Id$ |
## $Id$ |
4 |
## ------------------------------------------------------------------------------------- |
## ------------------------------------------------------------------------------------- |
5 |
## $Log$ |
## $Log$ |
6 |
|
## Revision 1.3 2002/12/06 04:12:54 joko |
7 |
|
## + replaced 'xyzCache' through 'xyzProxy' |
8 |
|
## + function store(...) |
9 |
|
## |
10 |
|
## Revision 1.2 2002/12/05 21:44:09 joko |
11 |
|
## + debugging |
12 |
|
## |
13 |
## Revision 1.1 2002/12/01 17:23:58 joko |
## Revision 1.1 2002/12/01 17:23:58 joko |
14 |
## + initial check-in |
## + initial check-in |
15 |
## |
## |
76 |
if ($objectId) { |
if ($objectId) { |
77 |
$this->objectId = $objectId; |
$this->objectId = $objectId; |
78 |
$this->load(); |
$this->load(); |
79 |
//$this->_saveCache(); |
//$this->_saveProxy(); |
80 |
} |
} |
81 |
} |
} |
82 |
|
|
83 |
function load() { |
function load() { |
84 |
if (!$this->_loadState()) { |
if (!$this->_loadState()) { |
85 |
if (!$this->_loadCache()) { |
if (!$this->_loadProxy()) { |
86 |
$this->_loadBackend(); |
$this->_loadBackend(); |
87 |
} |
} |
88 |
} |
} |
101 |
|
|
102 |
function flush() { |
function flush() { |
103 |
$this->flushState(); |
$this->flushState(); |
104 |
$this->flushCache(); |
$this->flushProxy(); |
105 |
} |
} |
106 |
|
|
107 |
function _commit() { |
function _commit() { |
108 |
$this->_saveBackend($this->attributes); |
$this->_saveBackend($this->attributes); |
109 |
$this->flushState(); |
$this->flushState(); |
110 |
$this->flushCache(); |
$this->flushProxy(); |
111 |
} |
} |
112 |
|
|
113 |
|
|
116 |
function _create() { |
function _create() { |
117 |
$this->_createBackend($this->attributes); |
$this->_createBackend($this->attributes); |
118 |
$this->flushState(); |
$this->flushState(); |
119 |
$this->flushCache(); |
$this->flushProxy(); |
120 |
} |
} |
121 |
*/ |
*/ |
122 |
|
|
132 |
$this->attributes = $data; |
$this->attributes = $data; |
133 |
} |
} |
134 |
|
|
135 |
function flushCache() { |
function flushProxy() { |
136 |
connectdb(); |
connectdb(); |
137 |
$sql = "DELETE FROM f_proxy WHERE oid='$this->objectId'"; |
$sql = "DELETE FROM f_proxy WHERE oid='$this->objectId'"; |
138 |
send_sql($sql); |
send_sql($sql); |
162 |
// TODO: throw exception-message back to user if operation fails |
// TODO: throw exception-message back to user if operation fails |
163 |
} |
} |
164 |
|
|
165 |
function _loadCache() { |
function _loadProxy() { |
166 |
logp(get_class($this) . "->_loadCache()", LOG_DEBUG); |
logp(get_class($this) . "->_loadProxy()", LOG_DEBUG); |
167 |
connectdb(); |
connectdb(); |
168 |
$sql = "SELECT payload FROM f_proxy WHERE oid='$this->objectId'"; |
$sql = "SELECT payload FROM f_proxy WHERE oid='$this->objectId'"; |
169 |
if ($res = send_sql($sql)) { |
if ($res = send_sql($sql)) { |
176 |
} |
} |
177 |
} |
} |
178 |
|
|
179 |
function _saveCache() { |
// TODO: use PEAR here |
180 |
logp(get_class($this) . "->_saveCache()", LOG_DEBUG); |
function _saveProxy() { |
181 |
|
logp(get_class($this) . "->_saveProxy()", LOG_DEBUG); |
182 |
connectdb(); |
connectdb(); |
183 |
if ($this->payload) { |
if ($this->payload) { |
184 |
//$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'"; |
194 |
logp(get_class($this) . "->_loadBackend()", LOG_DEBUG); |
logp(get_class($this) . "->_loadBackend()", LOG_DEBUG); |
195 |
// TODO: test backend for reachability first (eventually cache this information and "reset" it by another party) |
// TODO: test backend for reachability first (eventually cache this information and "reset" it by another party) |
196 |
if ($result = $this->backend->call('getObject', $this->objectId)) { |
if ($result = $this->backend->call('getObject', $this->objectId)) { |
197 |
//print dumpVar($result); |
//print "result: " . dumpVar($result) . "<br>"; |
198 |
if (count($result) == 0) { return; } |
if (count($result) == 0) { return; } |
199 |
$encoder = new TextEncode($result); |
$encoder = new TextEncode($result); |
200 |
$encoder->toISO(); |
$encoder->toISO(); |
202 |
print dumpVar($result); |
print dumpVar($result); |
203 |
} |
} |
204 |
$this->payload = serialize($result); |
$this->payload = serialize($result); |
205 |
$this->_saveCache(); |
$this->_saveProxy(); |
206 |
} |
} |
207 |
} |
} |
208 |
|
|
221 |
$this->meta[decoded] = 1; |
$this->meta[decoded] = 1; |
222 |
} |
} |
223 |
} |
} |
224 |
|
|
225 |
|
function store($struct) { |
226 |
|
$this->payload = serialize($struct); |
227 |
|
$this->_saveProxy(); |
228 |
|
} |
229 |
|
|
230 |
} |
} |
231 |
|
|