/** static */ function saveBlob($id, $name, $blob) { $obj = new sotf_Blob(); $obj->set('object_id', $id); $obj->set('name', $name); $obj->find(); if ($obj->exists()) { if ($blob) { $obj->setBlob('data', $blob); } else { $obj->delete(); } } else { if ($blob) { $obj->create(); $obj->setBlob('data', $blob); } // else nothing to do! } }
/** Static: saves the blob for the given object ('id') under the given name. */ function saveBlob($id, $name, $blob) { $obj = new sotf_Blob(); //debug("saving blob", substr($blob, 0, 40)); $obj->set('object_id', $id); $obj->set('name', $name); $obj->find(); $obj->set('data', $blob); if ($obj->exists()) { if ($blob) { $obj->update(); } else { $obj->delete(); } } else { if ($blob) { $obj->create(); } // else nothing to do! } }