12.2. Working with PostgreSQL BLOBs Using PHP
PHP's functions related to PostgreSQL and BLOBs are comfortable and easy to use. Functions are available for all important operations such as importing, exporting, creating a new object, or writing data into an object. As we have already seen, SQL offers counterparts to the functions provided by PHP. However, in this section you will learn to use PHP's onboard functions.
The next example shows how a file is imported into a database and deleted again:
<?php $dbh = pg_connect("host=localhost user=postgres dbname=phpbook"); if (!$dbh) { echo "error while connecting.<br>\n"; } pg_exec($dbh, "BEGIN"); $oid = pg_loimport('/etc/passwd', $dbh); if (!$oid) { echo "an error has occurred while importing<br>\n"; ...
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.