Firebird 2.0
PHP5 Programming
Manual

Overview of working with BLOBs

Blobs are binary large objects. Blobs can hold large blocks of text, images, or other large data objects. In Firebird, blobs are primarily accessed through blob identifiers.

Syntax

<blob_function> ::=
     <blob_create>
   | <blob_add>
   | <blob_cancel>
   | <blob_open>
   | <blob_get>>
   | <blob_close>
   | <blob_import>
   | <blob_echo>
   | <blob_info>



Description

The blob handling functions are:

  • blob_create
    This function creates a new blob to which data can be added and subsequently stored in a table

  • blob_add
    This function adds additional data to a blob that has been opened fro writing with blob_create

  • blob_cancel
    This function cancels a blob that has been created for writing. Any contents are discarded

  • blob_open
    This function opens a blob for reading with the blob_get function

  • blob_get
    This function retrieves a sequential chunk of data from the blob

  • blob_close
    This function closes a blob that is open for reading or writing

  • blob_import
    This function imports a file into a blob in a single operation

  • blob_echo
    This function echoes the contents of a blob directly to the browser


  • blob_info
    This function provides information about the size and type of a blob

Blob ID's and Blob handles

It is important to distinguish between blob ID's and blob handles, as the two are very different and easily confused.

  • A blob ID is an 8-byte string that identifies the blob inside the database. It is the blob ID that is stored into tables and retrieved from it.

  • A blob handle is a blob that has been opened for access. Typically a blob handle is obtained by first retrieving a blob ID from the database and then opening the blob by passing the blob ID to the blob_open function.

Note that you cannot rely on blob ID's being fixed for during the blob's lifetime. The blob ID changes on two occassions:

  • If a blob is created and closed it gets assigned a temporary blob ID. Only when the ID is inserted into a table, and the insert operation is committed, a different, permanent blob ID will be assigned.

  • This permanent blob ID can change during each backup – restore cycle. One can only be sure that a blob ID stays the same within a single transaction.


previous page goto index next page

Legal information