This chapter shall give you a quick introduction to BLOBs, their interface as adapted in PHPLIB and their respective usage.
In the process of making your application as portable as possible, you will always fall over one thing: Storing a special amount of data.
There are many existing implementations of BLOBs used by different vendors. These BLOBs are sometimes accessed by using a special API, sometimes with standard SQL. Sometimes they require you to pay attention to every single SQL statement you use.
The BLOB support folded into the db access class should make things easier for you and should guarantee (at least) code compatibility when using BLOBs.
If you are used to standard UNIX file descriptors, you will happily adapt this model. Every BLOB can be referenced by a unique integer ID which is only handled by the blob class.
The following is a short oversight how to use these BLOBs.
This will create a new BLOB and return its ID. If it is unpossible
to create a new BLOB, this function will halt()
the execution
and spit out some kind of error message.
Opens the specified BLOB for reading and writing and returns true or false, respectively.
Closes the referenced BLOB. Do not forget this - it maybe necessary for some databases or you will lose data.
Deletes the specified BLOB. All associated memory is deallocated. The BLOB doesn't may be referenced at a later time.
Reads the entire data of BLOB and returns it.
Overwrites the whole BLOB with $DATA.
This is a very light-weigth API which should be usable with every existing DBMS. There shouldn't be a problem with making it available through a file based system like GDBM or DB (unneeded for standard relational databases like MySQL, PostgreSQL or Informix).
It should help PHPLIB to support even more databases - the ones which cannot store massive amounts of data through a single INSERT/UPDATE statement.
I've done it already for PostgreSQL, we've seen a pseudo implementation for MySQL. Go for it :-)