<?php include("skipif.inc"); ?>
--FILE--
<?php
-include("createdb.inc");
+// create test table
+
+include('config.inc');
+
+$db = pg_connect($conn_str);
+if (!@pg_num_rows(@pg_query($db, "SELECT * FROM ".$table_name)))
+{
+ @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');");
+ }
+}
+else {
+ echo pg_last_error()."\n";
+}
+
+pg_close($db);
+
+echo "OK";
?>
--EXPECT--
OK
<?php include("skipif.inc"); ?>
--FILE--
<?php
-include("connection.inc");
+// connection function tests
+
+include('config.inc');
+
+$db = pg_pconnect($conn_str);
+if (pg_connection_status($db) != PGSQL_CONNECTION_OK)
+{
+ echo "pg_connection_status() error\n";
+}
+if (!pg_connection_reset($db))
+{
+ echo "pg_connection_reset() error\n";
+}
+if (pg_connection_busy($db))
+{
+ echo "pg_connection_busy() error\n";
+}
+if (!pg_host($db))
+{
+ echo "pg_host() error\n";
+}
+if (!pg_dbname($db))
+{
+ echo "pg_dbname() error\n";
+}
+if (!pg_port($db))
+{
+ echo "pg_port() error\n";
+}
+if (pg_tty($db))
+{
+ echo "pg_tty() error\n";
+}
+if (pg_options($db))
+{
+ echo "pg_options() error\n";
+}
+
+pg_close($db);
+
+echo "OK";
?>
--EXPECT--
OK
<?php include("skipif.inc"); ?>
--FILE--
<?php
-include("sync_query.inc");
+
+include('config.inc');
+
+$db = pg_connect($conn_str);
+
+$result = pg_query($db, "SELECT * FROM ".$table_name.";");
+if (!($rows = pg_num_rows($result)))
+{
+ echo "pg_num_row() error\n";
+}
+for ($i=0; $i < $rows; $i++)
+{
+ pg_fetch_array($result, $i, PGSQL_NUM);
+}
+for ($i=0; $i < $rows; $i++)
+{
+ pg_fetch_object($result, $i, PGSQL_ASSOC);
+}
+for ($i=0; $i < $rows; $i++)
+{
+ pg_fetch_row($result, $i);
+}
+for ($i=0; $i < $rows; $i++)
+{
+ pg_fetch_result($result, $i, 0);
+}
+
+pg_result_error($result);
+pg_num_rows(pg_query($db, "SELECT * FROM ".$table_name.";"));
+pg_num_fields(pg_query($db, "SELECT * FROM ".$table_name.";"));
+pg_field_name($result, 0);
+pg_field_num($result, $field_name);
+pg_field_size($result, 0);
+pg_field_type($result, 0);
+pg_field_prtlen($result, 0);
+pg_field_is_null($result, 0);
+
+$result = pg_query($db, "INSERT INTO ".$table_name." VALUES (9999, 'ABC');");
+pg_last_oid($result);
+
+pg_free_result($result);
+pg_close($db);
+
+echo "OK";
?>
--EXPECT--
OK
<?php include("skipif.inc"); ?>
--FILE--
<?php
-include("async_query.inc");
+
+include('config.inc');
+
+$db = pg_connect($conn_str);
+
+if (!pg_send_query($db, "SELECT * FROM ".$table_name.";")) {
+ echo "pg_send_query() error\n";
+}
+while(pg_connection_busy($db)); // busy wait: intended
+if (pg_connection_status($db) === PGSQL_CONNECTION_BAD) {
+ echo "pg_connection_status() error\n";
+}
+if (!($result = pg_get_result($db)))
+{
+ echo "pg_get_result() error\n";
+}
+
+if (!($rows = pg_num_rows($result))) {
+ echo "pg_num_rows() error\n";
+}
+for ($i=0; $i < $rows; $i++)
+{
+ pg_fetch_array($result, $i, PGSQL_NUM);
+}
+for ($i=0; $i < $rows; $i++)
+{
+ pg_fetch_object($result, $i, PGSQL_ASSOC);
+}
+for ($i=0; $i < $rows; $i++)
+{
+ pg_fetch_row($result, $i);
+}
+for ($i=0; $i < $rows; $i++)
+{
+ pg_fetch_result($result, $i, 0);
+}
+
+pg_num_rows(pg_query($db, "SELECT * FROM ".$table_name.";"));
+pg_num_fields(pg_query($db, "SELECT * FROM ".$table_name.";"));
+pg_field_name($result, 0);
+pg_field_num($result, $field_name);
+pg_field_size($result, 0);
+pg_field_type($result, 0);
+pg_field_prtlen($result, 0);
+pg_field_is_null($result, 0);
+
+if (!pg_send_query($db, "INSERT INTO ".$table_name." VALUES (8888, 'GGG');"))
+{
+ echo "pg_send_query() error\n";
+}
+
+pg_last_oid($result);
+pg_free_result($result);
+
+
+echo "OK";
?>
--EXPECT--
OK
<?php include("skipif.inc"); ?>
--FILE--
<?php
-include("large_object.inc");
+
+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");
+$handle = pg_lo_open ($db, $oid, "w");
+if (!$handle) echo ("pg_lo_open() error\n");
+pg_lo_write ($handle, "large object data\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_tell($handle);
+pg_lo_seek($handle, 2);
+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);
+if (pg_last_error()) echo "pg_lo_read_all() error\n".pg_last_error();
+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");
+
+// more pg_lo_unlink() tests
+// Test without connection
+pg_exec ($db, "begin");
+$oid = pg_lo_create ($db) or print("pg_lo_create() error\n");
+pg_lo_unlink($oid) or print("pg_lo_unlink() error\n");
+pg_exec ($db, "commit");
+
+// Test with string oid value
+pg_exec ($db, "begin");
+$oid = pg_lo_create ($db) or print("pg_lo_create() error\n");
+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";
?>
--EXPECT--
large object data
<?php include("skipif.inc"); ?>
--FILE--
<?php
-include("copy.inc");
+
+include('config.inc');
+
+
+echo "OK";
+
?>
--EXPECT--
OK
<?php include("skipif.inc"); ?>
--FILE--
<?php
-include("optional.inc");
+// optional functions
+
+include('config.inc');
+
+$db = pg_connect($conn_str);
+$enc = pg_client_encoding($db);
+
+pg_set_client_encoding($db, $enc);
+
+echo "OK";
?>
--EXPECT--
OK
<?php include("skipif.inc"); ?>
--FILE--
<?php
-include("escape.inc");
+
+include 'config.inc';
+define('FILE_NAME', './php.gif');
+
+// pg_escape_string() test
+$before = "ABC\\ABC\'";
+$expect = "ABC\\\\ABC\\'";
+$after = pg_escape_string($before);
+if ($expect === $after) {
+ echo "pg_escape_string() is Ok\n";
+}
+else {
+ echo "pg_escape_string() is NOT Ok\n";
+ var_dump($before);
+ var_dump($after);
+ var_dump($expect);
+}
+
+// pg_escape_bytea() test
+$before = "ABC\\ABC";
+$expect = "ABC\\\\\\\\ABC";
+$after = pg_escape_bytea($before);
+if ($expect === $after) {
+ echo "pg_escape_bytea() is Ok\n";
+}
+else {
+ echo "pg_escape_byte() is NOT Ok\n";
+ var_dump($before);
+ var_dump($after);
+ var_dump($expect);
+}
+
+// Test using database
+$fp = fopen(FILE_NAME,'r');
+$data = fread($fp, filesize(FILE_NAME));
+$db = pg_connect($conn_str);
+
+// Insert binary to DB
+$escaped_data = pg_escape_bytea($data);
+pg_query("DELETE FROM ".$table_name." WHERE num = -9999;");
+$sql = "INSERT INTO ".$table_name." (num, bin) VALUES (-9999, CAST ('".$escaped_data."' AS BYTEA));";
+pg_query($db, $sql);
+
+// Retrieve binary from DB
+$sql = "SELECT bin::bytea FROM ".$table_name." WHERE num = -9999";
+$result = pg_query($db, $sql);
+$row = pg_fetch_array($result, 0, PGSQL_ASSOC);
+
+// Compare
+// Need to wait PostgreSQL 7.3.x for PQunescapeBytea()
+// if ($data === pg_unescape_bytea($row['bin'])) {
+// echo "pg_escape_bytea() actually works with databse\n";
+// }
+// else {
+// echo "pg_escape_bytea() is broken\n";
+// }
+
?>
--EXPECT--
pg_escape_string() is NOT Ok
<?php include("skipif.inc"); ?>
--FILE--
<?php
-include("notice.inc");
+include 'config.inc';
+
+ini_set('pgsql.log_notice',1);
+
+$db = pg_connect($conn_str);
+pg_query($db, "BEGIN;");
+pg_query($db, "BEGIN;");
+
+$msg = pg_last_notice($db);
+if ($msg === FALSE) {
+ echo "Cannot find notice message in hash\n";
+ var_dump($msg);
+}
+echo $msg;
+echo "pg_last_notice() is Ok\n";
+
?>
--EXPECT--
NOTICE: BEGIN: already a transaction in progress
<?php include("skipif.inc"); ?>
--FILE--
<?php
-include("pg_convert.inc");
+error_reporting(E_ALL);
+
+include 'config.inc';
+
+$db = pg_connect($conn_str);
+
+$fields = array('num'=>'1234', 'str'=>'AAA', 'bin'=>'BBB');
+$converted = pg_convert($db, $table_name, $fields);
+
+var_dump($converted);
?>
--EXPECT--
array(3) {
<?php include("skipif.inc"); ?>
--FILE--
<?php
-include("pg_meta_data.inc");
+error_reporting(E_ALL);
+
+include 'config.inc';
+
+$db = pg_connect($conn_str);
+
+$meta = pg_meta_data($db, $table_name);
+
+var_dump($meta);
?>
--EXPECT--
array(3) {
<?php include("skipif.inc"); ?>
--FILE--
<?php
-include("pg_insert.inc");
+error_reporting(E_ALL);
+
+include 'config.inc';
+
+$db = pg_connect($conn_str);
+$fields = array('num'=>'1234', 'str'=>'AAA', 'bin'=>'BBB');
+
+pg_insert($db, $table_name, $fields) or print "Error in test 1\n";
+echo pg_insert($db, $table_name, $fields, PGSQL_DML_STRING)."\n";
+
+echo "Ok\n";
?>
--EXPECT--
INSERT INTO php_pgsql_test (num,str,bin) VALUES (1234,'AAA','BBB');
<?php include("skipif.inc"); ?>
--FILE--
<?php
-include("pg_select.inc");
+error_reporting(E_ALL);
+
+include 'config.inc';
+
+$db = pg_connect($conn_str);
+$fields = array('num'=>'1234', 'str'=>'ABC', 'bin'=>'XYZ');
+$ids = array('num'=>'1234');
+
+$res = pg_select($db, $table_name, $ids) or print "Error\n";
+var_dump($res);
+echo pg_select($db, $table_name, $ids, PGSQL_DML_STRING)."\n";
+echo "Ok\n";
+
?>
--EXPECT--
array(1) {
<?php include("skipif.inc"); ?>
--FILE--
<?php
-include("pg_update.inc");
+error_reporting(E_ALL);
+
+include 'config.inc';
+
+$db = pg_connect($conn_str);
+$fields = array('num'=>'1234', 'str'=>'ABC', 'bin'=>'XYZ');
+$ids = array('num'=>'1234');
+
+pg_update($db, $table_name, $fields, $ids) or print "Error in test 1\n";
+echo pg_update($db, $table_name, $fields, $ids, PGSQL_DML_STRING)."\n";
+
+echo "Ok\n";
?>
--EXPECT--
UPDATE php_pgsql_test SET num=1234,str='ABC',bin='XYZ' WHERE num=1234;
<?php include("skipif.inc"); ?>
--FILE--
<?php
-include("pg_delete.inc");
+error_reporting(E_ALL);
+
+include 'config.inc';
+
+$db = pg_connect($conn_str);
+
+$fields = array('num'=>'1234', 'str'=>'XXX', 'bin'=>'YYY');
+$ids = array('num'=>'1234');
+if (!pg_delete($db, $table_name, $ids)) {
+ echo "Error\n";
+}
+else {
+ echo "Ok\n";
+}
?>
--EXPECT--
Ok
<?php include("skipif.inc"); ?>
--FILE--
<?php
-include("pg_result_status.inc");
+include 'config.inc';
+
+$db = pg_connect($conn_str);
+
+$sql = "SELECT * FROM ".$table_name." WHERE num = -2";
+$result = pg_query($db, "BEGIN;END");
+
+echo pg_result_status($result)."\n";
+echo pg_result_status($result, PGSQL_STATUS_STRING)."\n";
?>
--EXPECT--
1
<?php include("skipif.inc"); ?>
--FILE--
<?php
-include("result.inc");
+error_reporting(E_ALL);
+
+include 'config.inc';
+
+$db = pg_connect($conn_str);
+
+$sql = "SELECT * FROM $table_name";
+$result = pg_query($db, $sql) or die('Cannot qeury db');
+$rows = pg_num_rows($result);
+
+var_dump(pg_fetch_object($result, 1));
+var_dump(pg_fetch_array($result, 1));
+var_dump(pg_fetch_row($result, 1));
+var_dump(pg_fetch_assoc($result, 1));
+var_dump(pg_result_seek($result, 0));
+
+echo "Ok\n";
?>
--EXPECT--
-object(stdClass)(3) {
+object(stdClass)#1 (3) {
["num"]=>
string(1) "1"
["str"]=>
}
array(3) {
["num"]=>
- string(1) "2"
+ string(1) "1"
["str"]=>
string(3) "ABC"
["bin"]=>
<?php include("skipif.inc"); ?>
--FILE--
<?php
-include("pg_escape_bytea.inc");
+// 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";
+}
?>
--EXPECT--
OK
<?php include("skipif.inc"); ?>
--FILE--
<?php
-include("pg_ping.inc");
+// optional functions
+
+include('config.inc');
+
+$db = pg_connect($conn_str);
+var_dump(pg_ping($db));
?>
--EXPECT--
bool(true)
<?php include("skipif.inc"); ?>
--FILE--
<?php
-include("pg_get_pid.inc");
+// optional functions
+
+include('config.inc');
+
+$db = pg_connect($conn_str);
+$pid = pg_get_pid($db);
+
+is_integer($pid) ? print 'OK' : print 'NG';
?>
--EXPECT--
OK
<?php include("skipif.inc"); ?>
--FILE--
<?php
-include("pg_get_notify.inc");
+// 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';
?>
--EXPECT--
OK
<?php include("skipif.inc"); ?>
--FILE--
<?php
-include("old_api.inc");
+
+include('config.inc');
+
+$db = pg_connect($conn_str);
+$result = pg_exec("SELECT * FROM ".$table_name);
+pg_numrows($result);
+pg_numfields($result);
+pg_fieldname($result, 0);
+pg_fieldsize($result, $field_name);
+pg_fieldtype($result, 0);
+pg_fieldprtlen($result, 0);
+pg_fieldisnull($result, 0);
+
+pg_result($result,0,0);
+$result = pg_exec("INSERT INTO ".$table_name." VALUES (7777, 'KKK')");
+$oid = pg_getlastoid($result);
+pg_freeresult($result);
+pg_errormessage();
+$result = pg_exec("UPDATE ".$table_name." SET str = 'QQQ' WHERE str like 'RGD';");
+pg_cmdtuples($result);
+
+
+
+echo "OK";
?>
--EXPECT--
OK
<?php include("skipif.inc"); ?>
--FILE--
<?php
-include("dropdb.inc");
+// drop test table
+
+include('config.inc');
+
+$db = pg_connect($conn_str);
+pg_query($db, "DROP TABLE ".$table_name);
+
+echo "OK";
+
?>
--EXPECT--
OK
+++ /dev/null
-<?php
-
-include('config.inc');
-
-$db = pg_connect($conn_str);
-
-if (!pg_send_query($db, "SELECT * FROM ".$table_name.";")) {
- echo "pg_send_query() error\n";
-}
-while(pg_connection_busy($db)); // busy wait: intended
-if (pg_connection_status($db) === PGSQL_CONNECTION_BAD) {
- echo "pg_connection_status() error\n";
-}
-if (!($result = pg_get_result($db)))
-{
- echo "pg_get_result() error\n";
-}
-
-if (!($rows = pg_num_rows($result))) {
- echo "pg_num_rows() error\n";
-}
-for ($i=0; $i < $rows; $i++)
-{
- pg_fetch_array($result, $i, PGSQL_NUM);
-}
-for ($i=0; $i < $rows; $i++)
-{
- pg_fetch_object($result, $i, PGSQL_ASSOC);
-}
-for ($i=0; $i < $rows; $i++)
-{
- pg_fetch_row($result, $i);
-}
-for ($i=0; $i < $rows; $i++)
-{
- pg_fetch_result($result, $i, 0);
-}
-
-pg_num_rows(pg_query($db, "SELECT * FROM ".$table_name.";"));
-pg_num_fields(pg_query($db, "SELECT * FROM ".$table_name.";"));
-pg_field_name($result, 0);
-pg_field_num($result, $field_name);
-pg_field_size($result, 0);
-pg_field_type($result, 0);
-pg_field_prtlen($result, 0);
-pg_field_is_null($result, 0);
-
-if (!pg_send_query($db, "INSERT INTO ".$table_name." VALUES (8888, 'GGG');"))
-{
- echo "pg_send_query() error\n";
-}
-
-pg_last_oid($result);
-pg_free_result($result);
-
-
-echo "OK";
-
-?>
\ No newline at end of file
+++ /dev/null
-<?php
-// connection function tests
-
-include('config.inc');
-
-$db = pg_pconnect($conn_str);
-if (pg_connection_status($db) != PGSQL_CONNECTION_OK)
-{
- echo "pg_connection_status() error\n";
-}
-if (!pg_connection_reset($db))
-{
- echo "pg_connection_reset() error\n";
-}
-if (pg_connection_busy($db))
-{
- echo "pg_connection_busy() error\n";
-}
-if (!pg_host($db))
-{
- echo "pg_host() error\n";
-}
-if (!pg_dbname($db))
-{
- echo "pg_dbname() error\n";
-}
-if (!pg_port($db))
-{
- echo "pg_port() error\n";
-}
-if (pg_tty($db))
-{
- echo "pg_tty() error\n";
-}
-if (pg_options($db))
-{
- echo "pg_options() error\n";
-}
-
-pg_close($db);
-
-echo "OK";
-
-?>
\ No newline at end of file
+++ /dev/null
-<?php
-
-include('config.inc');
-
-
-echo "OK";
-
-?>
\ No newline at end of file
+++ /dev/null
-<?php
-// create test table
-
-include('config.inc');
-
-$db = pg_connect($conn_str);
-if (!@pg_num_rows(@pg_query($db, "SELECT * FROM ".$table_name)))
-{
- @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');");
- }
-}
-else {
- echo pg_last_error()."\n";
-}
-
-pg_close($db);
-
-echo "OK";
-
-?>
\ No newline at end of file
+++ /dev/null
-<?php
-// drop test table
-
-include('config.inc');
-
-$db = pg_connect($conn_str);
-pg_query($db, "DROP TABLE ".$table_name);
-
-echo "OK";
-
-?>
\ No newline at end of file
+++ /dev/null
-<?php
-
-include 'config.inc';
-define('FILE_NAME', './php.gif');
-
-// pg_escape_string() test
-$before = "ABC\\ABC\'";
-$expect = "ABC\\\\ABC\\'";
-$after = pg_escape_string($before);
-if ($expect === $after) {
- echo "pg_escape_string() is Ok\n";
-}
-else {
- echo "pg_escape_string() is NOT Ok\n";
- var_dump($before);
- var_dump($after);
- var_dump($expect);
-}
-
-// pg_escape_bytea() test
-$before = "ABC\\ABC";
-$expect = "ABC\\\\\\\\ABC";
-$after = pg_escape_bytea($before);
-if ($expect === $after) {
- echo "pg_escape_bytea() is Ok\n";
-}
-else {
- echo "pg_escape_byte() is NOT Ok\n";
- var_dump($before);
- var_dump($after);
- var_dump($expect);
-}
-
-// Test using database
-$fp = fopen(FILE_NAME,'r');
-$data = fread($fp, filesize(FILE_NAME));
-$db = pg_connect($conn_str);
-
-// Insert binary to DB
-$escaped_data = pg_escape_bytea($data);
-pg_query("DELETE FROM ".$table_name." WHERE num = -9999;");
-$sql = "INSERT INTO ".$table_name." (num, bin) VALUES (-9999, CAST ('".$escaped_data."' AS BYTEA));";
-pg_query($db, $sql);
-
-// Retrieve binary from DB
-$sql = "SELECT bin::bytea FROM ".$table_name." WHERE num = -9999";
-$result = pg_query($db, $sql);
-$row = pg_fetch_array($result, 0, PGSQL_ASSOC);
-
-// Compare
-// Need to wait PostgreSQL 7.3.x for PQunescapeBytea()
-// if ($data === pg_unescape_bytea($row['bin'])) {
-// echo "pg_escape_bytea() actually works with databse\n";
-// }
-// else {
-// echo "pg_escape_bytea() is broken\n";
-// }
-
-?>
+++ /dev/null
-<?php
-// connection function tests
-
-include('config.inc');
-
-$db = pg_pconnect($conn_str);
-if (pg_connection_status($db) != PGSQL_CONNECTION_OK)
-{
- echo "pg_connection_status() error\n";
-}
-if (!pg_connection_reset($db))
-{
- echo "pg_connection_reset() error\n";
-}
-if (pg_connection_busy($db))
-{
- echo "pg_connection_busy() error\n";
-}
-if (!pg_host($db))
-{
- echo "pg_host() error\n";
-}
-if (!pg_dbname($db))
-{
- echo "pg_dbname() error\n";
-}
-if (!pg_port($db))
-{
- echo "pg_port() error\n";
-}
-if (pg_tty($db))
-{
- echo "pg_tty() error\n";
-}
-if (pg_options($db))
-{
- echo "pg_options() error\n";
-}
-
-echo pg_host($db);
-
-
-pg_close($db);
-
-echo "OK";
-
-?>
\ No newline at end of file
+++ /dev/null
-<?php
-
-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");
-$handle = pg_lo_open ($db, $oid, "w");
-if (!$handle) echo ("pg_lo_open() error\n");
-pg_lo_write ($handle, "large object data\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_tell($handle);
-pg_lo_seek($handle, 2);
-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);
-if (pg_last_error()) echo "pg_lo_read_all() error\n".pg_last_error();
-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");
-
-// more pg_lo_unlink() tests
-// Test without connection
-pg_exec ($db, "begin");
-$oid = pg_lo_create ($db) or print("pg_lo_create() error\n");
-pg_lo_unlink($oid) or print("pg_lo_unlink() error\n");
-pg_exec ($db, "commit");
-
-// Test with string oid value
-pg_exec ($db, "begin");
-$oid = pg_lo_create ($db) or print("pg_lo_create() error\n");
-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
-include 'config.inc';
-
-ini_set('pgsql.log_notice',1);
-
-$db = pg_connect($conn_str);
-pg_query($db, "BEGIN;");
-pg_query($db, "BEGIN;");
-
-$msg = pg_last_notice($db);
-if ($msg === FALSE) {
- echo "Cannot find notice message in hash\n";
- var_dump($msg);
-}
-echo $msg;
-echo "pg_last_notice() is Ok\n";
-
-?>
+++ /dev/null
-<?php
-
-include('config.inc');
-
-$db = pg_connect($conn_str);
-$result = pg_exec("SELECT * FROM ".$table_name);
-pg_numrows($result);
-pg_numfields($result);
-pg_fieldname($result, 0);
-pg_fieldsize($result, $field_name);
-pg_fieldtype($result, 0);
-pg_fieldprtlen($result, 0);
-pg_fieldisnull($result, 0);
-
-pg_result($result,0,0);
-$result = pg_exec("INSERT INTO ".$table_name." VALUES (7777, 'KKK')");
-$oid = pg_getlastoid($result);
-pg_freeresult($result);
-pg_errormessage();
-$result = pg_exec("UPDATE ".$table_name." SET str = 'QQQ' WHERE str like 'RGD';");
-pg_cmdtuples($result);
-
-
-
-echo "OK";
-?>
\ No newline at end of file
+++ /dev/null
-<?php
-// optional functions
-
-include('config.inc');
-
-$db = pg_connect($conn_str);
-$enc = pg_client_encoding($db);
-
-pg_set_client_encoding($db, $enc);
-
-echo "OK";
-
-?>
\ No newline at end of file
+++ /dev/null
-<?php
-error_reporting(E_ALL);
-
-include 'config.inc';
-
-$db = pg_connect($conn_str);
-
-$fields = array('num'=>'1234', 'str'=>'AAA', 'bin'=>'BBB');
-$converted = pg_convert($db, $table_name, $fields);
-
-var_dump($converted);
-
-
-?>
+++ /dev/null
-<?php
-error_reporting(E_ALL);
-
-include 'config.inc';
-
-$db = pg_connect($conn_str);
-
-$fields = array('num'=>'1234', 'str'=>'XXX', 'bin'=>'YYY');
-$ids = array('num'=>'1234');
-if (!pg_delete($db, $table_name, $ids)) {
- echo "Error\n";
-}
-else {
- echo "Ok\n";
-}
-
-?>
\ 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
-error_reporting(E_ALL);
-
-include 'config.inc';
-
-$db = pg_connect($conn_str);
-$fields = array('num'=>'1234', 'str'=>'AAA', 'bin'=>'BBB');
-
-pg_insert($db, $table_name, $fields) or print "Error in test 1\n";
-echo pg_insert($db, $table_name, $fields, PGSQL_DML_STRING)."\n";
-
-echo "Ok\n";
-?>
+++ /dev/null
-<?php
-error_reporting(E_ALL);
-
-include 'config.inc';
-
-$db = pg_connect($conn_str);
-
-$meta = pg_meta_data($db, $table_name);
-
-var_dump($meta);
-
-
-?>
+++ /dev/null
-<?php
-// optional functions
-
-include('config.inc');
-
-$db = pg_connect($conn_str);
-var_dump(pg_ping($db));
-
-
-?>
\ No newline at end of file
+++ /dev/null
-<?php
-include 'config.inc';
-
-$db = pg_connect($conn_str);
-
-$sql = "SELECT * FROM ".$table_name." WHERE num = -2";
-$result = pg_query($db, "BEGIN;END");
-
-echo pg_result_status($result)."\n";
-echo pg_result_status($result, PGSQL_STATUS_STRING)."\n";
-
-
-?>
\ No newline at end of file
+++ /dev/null
-<?php
-error_reporting(E_ALL);
-
-include 'config.inc';
-
-$db = pg_connect($conn_str);
-$fields = array('num'=>'1234', 'str'=>'ABC', 'bin'=>'XYZ');
-$ids = array('num'=>'1234');
-
-$res = pg_select($db, $table_name, $ids) or print "Error\n";
-var_dump($res);
-echo pg_select($db, $table_name, $ids, PGSQL_DML_STRING)."\n";
-echo "Ok\n";
-
-?>
\ No newline at end of file
+++ /dev/null
-<?php
-error_reporting(E_ALL);
-
-include 'config.inc';
-
-$db = pg_connect($conn_str);
-$fields = array('num'=>'1234', 'str'=>'ABC', 'bin'=>'XYZ');
-$ids = array('num'=>'1234');
-
-pg_update($db, $table_name, $fields, $ids) or print "Error in test 1\n";
-echo pg_update($db, $table_name, $fields, $ids, PGSQL_DML_STRING)."\n";
-
-echo "Ok\n";
-
-?>
+++ /dev/null
-<?php
-error_reporting(E_ALL);
-
-include 'config.inc';
-
-$db = pg_connect($conn_str);
-
-$sql = "SELECT * FROM $table_name";
-$result = pg_query($db, $sql) or die('Cannot qeury db');
-$rows = pg_num_rows($result);
-
-$rec = pg_fetch_object($result, 1);
-var_dump($rec);
-$rec = pg_fetch_array($result, 1);
-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";
-
-?>
\ No newline at end of file
+++ /dev/null
-<?php
-
-include('config.inc');
-
-$db = pg_connect($conn_str);
-
-$result = pg_query($db, "SELECT * FROM ".$table_name.";");
-if (!($rows = pg_num_rows($result)))
-{
- echo "pg_num_row() error\n";
-}
-for ($i=0; $i < $rows; $i++)
-{
- pg_fetch_array($result, $i, PGSQL_NUM);
-}
-for ($i=0; $i < $rows; $i++)
-{
- pg_fetch_object($result, $i, PGSQL_ASSOC);
-}
-for ($i=0; $i < $rows; $i++)
-{
- pg_fetch_row($result, $i);
-}
-for ($i=0; $i < $rows; $i++)
-{
- pg_fetch_result($result, $i, 0);
-}
-
-pg_result_error($result);
-pg_num_rows(pg_query($db, "SELECT * FROM ".$table_name.";"));
-pg_num_fields(pg_query($db, "SELECT * FROM ".$table_name.";"));
-pg_field_name($result, 0);
-pg_field_num($result, $field_name);
-pg_field_size($result, 0);
-pg_field_type($result, 0);
-pg_field_prtlen($result, 0);
-pg_field_is_null($result, 0);
-
-$result = pg_query($db, "INSERT INTO ".$table_name." VALUES (9999, 'ABC');");
-pg_last_oid($result);
-
-pg_free_result($result);
-pg_close($db);
-
-echo "OK";
-
-?>
\ No newline at end of file