PHP midgard_blob
This is experimental section.
midgard_blob class provides transparent access to real files located in filesystem. It's a proxy between database objects and files like images or documents.
Minimum version: 1.9
Creating new midgard_blob instance ( constructor )
Midgard Blob object is instantiated with attachment object as parameter. It's not defined in Mgdschema xml files, and it's currently convention to initialize blob for object with location property which are designed as any object's attachments.
object midgard_blob(midgard_attachment object);
Basically, to manage binary data ( blobs ) in Midgard you need three different kind of objects:
- Any MgdSchema object
- midgard_atachment
- midgard_blob
This may look a bit overloaded but in fact this approach brings many flexibility:
- Binary data doesn't have to be stored together with database record ( Midgard object ).
- One object may have unlimited attachments.
- One blob may be shared among different objects ( of different classes even ).
- You may attach attachment to another attachment ( notes to documentation or image thumbnails ).
- Binary file is independent from objects
If attachment hasn't been created yet, midgard_blob will internally create it's relative location. There is no need to define location for newly created attachments.
Read write_content example.
