pg_exec ($db, "commit");
echo "import/export LO\n";
+$path = dirname(__FILE__) . '/';
pg_query($db, 'begin');
-$oid = pg_lo_import($db, 'php.gif');
+$oid = pg_lo_import($db, $path . 'php.gif');
pg_query($db, 'commit');
pg_query($db, 'begin');
-@unlink('php.gif.exported');
-pg_lo_export($oid, 'php.gif.exported', $db);
-if (!file_exists('php.gif.exported')) {
+@unlink($path . 'php.gif.exported');
+pg_lo_export($oid, $path . 'php.gif.exported', $db);
+if (!file_exists($path . 'php.gif.exported')) {
echo "Export failed\n";
}
-@unlink('php.gif.exported');
+@unlink($path . 'php.gif.exported');
pg_query($db, 'commit');
echo "OK";
<?php
include 'config.inc';
-define('FILE_NAME', './php.gif');
+define('FILE_NAME', dirname(__FILE__) . '/php.gif');
// pg_escape_string() test
$before = "ABC\\ABC\'";
}
// Test using database
-$fp = fopen(FILE_NAME,'r');
-$data = fread($fp, filesize(FILE_NAME));
+$data = file_get_contents(FILE_NAME);
$db = pg_connect($conn_str);
// Insert binary to DB
include('config.inc');
-$fp = fopen('php.gif', 'r');
-$image = fread($fp, filesize('php.gif'));
+$image = file_get_contents(dirname(__FILE__) . '/php.gif');
$esc_image = pg_escape_bytea($image);
$db = pg_connect($conn_str);