12.4. Storing Files as Toasted Text

Up to now you have seen how binary data can be stored without using PHP's and PostgreSQL's BLOB interface. Many people don't like to work with BLOBs, so it is necessary to find a different solution. In the case of PHP and PostgreSQL, data can be converted to hex code and stored in a text variable. Up to PostgreSQL 7.0, the size of text variables was limited to the size of one page, which is usually 8192 bytes. With the arrival of PostgreSQL 7.1, things have changed and text is a so-called toasted data type now, which means that one field can be larger than one page used by PostgreSQL internally. Currently, a field can have a size of up to 1GB. In many cases this will be enough. If you want to work with fields ...

Get PHP and PostgreSQL: Advanced Web Programming now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.