[2]=>
NULL
}
+array(3) {
+ ["num"]=>
+ string(1) "2"
+ ["str"]=>
+ string(3) "ABC"
+ ["bin"]=>
+ NULL
+}
+bool(true)
Ok
--- /dev/null
+--TEST--
+PostgreSQL pg_escape_bytea() functions
+--SKIPIF--
+<?php include("skipif.inc"); ?>
+--FILE--
+<?php
+include("pg_escape_bytea.inc");
+?>
+--EXPECT--
+OK
--- /dev/null
+--TEST--
+PostgreSQL pg_ping() functions
+--SKIPIF--
+<?php include("skipif.inc"); ?>
+--FILE--
+<?php
+include("pg_ping.inc");
+?>
+--EXPECT--
+bool(true)
--- /dev/null
+--TEST--
+PostgreSQL pg_get_pid() functions
+--SKIPIF--
+<?php include("skipif.inc"); ?>
+--FILE--
+<?php
+include("pg_get_pid.inc");
+?>
+--EXPECT--
+OK
--- /dev/null
+--TEST--
+PostgreSQL pg_get_notify() functions
+--SKIPIF--
+<?php include("skipif.inc"); ?>
+--FILE--
+<?php
+include("pg_get_notify.inc");
+?>
+--EXPECT--
+OK
--- /dev/null
+Test scripts assume:
+ - PostgreSQL server is installed locally
+ - there is a PostgreSQL account for the users running test script
+ - there is database named "test"
+
+For instance, if you login name is 'testuser', you should
+have PostgreSQL user account named 'testuser' and have 'test'
+database.
+
+If you have account and database, type "createdb test" from
+command prompt to create database to execute test scripts.
+
+If you find problems in PostgreSQL module, please mail to
+yohgaki@php.net or php-dev@lists.php.net.
$db = pg_connect($conn_str);
if (!@pg_num_rows(@pg_query($db, "SELECT * FROM ".$table_name)))
{
- @pg_query($db,$table_def);
+ @pg_query($db,$table_def); // Create table here
for ($i=0; $i < $num_test_record; $i++) {
pg_query($db,"INSERT INTO ".$table_name." VALUES ($i, 'ABC');");
}
include('config.inc');
$db = pg_connect($conn_str);
+
+// create/write/close LO
pg_exec ($db, "begin");
$oid = pg_lo_create ($db);
if (!$oid) echo ("pg_lo_create() error\n");
pg_lo_close ($handle);
pg_exec ($db, "commit");
+// open/read/tell/seek/close LO
pg_exec ($db, "begin");
$handle = pg_lo_open ($db, $oid, "w");
pg_lo_read($handle, 100);
pg_lo_close($handle);
pg_exec ($db, "commit");
+// open/read_all/close LO
pg_exec ($db, "begin");
$handle = pg_lo_open ($db, $oid, "w");
pg_lo_read_all($handle);
pg_lo_close($handle);
pg_exec ($db, "commit");
+// unlink LO
pg_exec ($db, "begin");
pg_lo_unlink($db, $oid) or print("pg_lo_unlink() error\n");
pg_exec ($db, "commit");
pg_lo_unlink($db, (string)$oid) or print("pg_lo_unlink() error\n");
pg_exec ($db, "commit");
+// import/export LO
+pg_query($db, 'begin');
+$oid = pg_lo_import($db, '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')) {
+ echo "Export failed\n";
+}
+@unlink('php.gif.exported');
+pg_query($db, 'commit');
+
echo "OK";
?>
\ No newline at end of file
--- /dev/null
+<?php
+// optional functions
+
+include('config.inc');
+
+
+$fp = fopen('php.gif', 'r');
+$image = fread($fp, filesize('php.gif'));
+$esc_image = pg_escape_bytea($image);
+
+$db = pg_connect($conn_str);
+pg_query($db, 'INSERT INTO '.$table_name.' (num, bin) VALUES (9876, \''.$esc_image.'\');');
+$result = pg_query($db, 'SELECT * FROM '.$table_name.' WHERE num = 9876');
+$rows = pg_fetch_all($result);
+$unesc_image = pg_unescape_bytea($rows[0]['bin']);
+
+if ($unesc_image !== $image) {
+ echo "NG";
+}
+else {
+ echo "OK";
+}
+
+
+?>
\ No newline at end of file
--- /dev/null
+<?php
+// optional functions
+
+include('config.inc');
+
+
+$db = pg_connect($conn_str);
+pg_query($db, 'LISTEN test_msg');
+pg_query($db, 'NOTIFY test_msg');
+
+$msg = pg_get_notify($db);
+
+isset($msg['message'],$msg['pid']) ? print 'OK' : print 'NG';
+
+
+?>
\ No newline at end of file
--- /dev/null
+<?php
+// optional functions
+
+include('config.inc');
+
+
+$db = pg_connect($conn_str);
+$pid = pg_get_pid($db);
+
+is_integer($pid) ? print 'OK' : print 'NG';
+
+
+?>
\ No newline at end of file
--- /dev/null
+<?php
+// optional functions
+
+include('config.inc');
+
+$db = pg_connect($conn_str);
+var_dump(pg_ping($db));
+
+
+?>
\ No newline at end of file
var_dump($rec);
$rec = pg_fetch_row($result, 1);
var_dump($rec);
+$rec = pg_fetch_assoc($result);
+var_dump($rec);
+var_dump(pg_result_seek($result, 0));
echo "Ok\n";