From e7e0eddadd0931c45208c393b340085e9c550852 Mon Sep 17 00:00:00 2001 From: Yasuo Ohgaki Date: Tue, 23 Apr 2002 03:42:26 +0000 Subject: Make pg_convert/pg_insert/pg_select/pg_update/pg_delete a bit more flexible. pg_convert() may ignore, NOT NULL and/or DEFAULT. pg_insert/pg_update/pg_select/pg_update may return query string. --- ext/pgsql/tests/12pg_insert.phpt | 1 + ext/pgsql/tests/13pg_select.phpt | 1 + ext/pgsql/tests/14pg_update.phpt | 1 + ext/pgsql/tests/pg_delete.inc | 2 +- ext/pgsql/tests/pg_insert.inc | 11 ++++------- ext/pgsql/tests/pg_select.inc | 15 ++++++--------- ext/pgsql/tests/pg_update.inc | 14 ++++++-------- 7 files changed, 20 insertions(+), 25 deletions(-) (limited to 'ext/pgsql/tests') diff --git a/ext/pgsql/tests/12pg_insert.phpt b/ext/pgsql/tests/12pg_insert.phpt index 8070df1539..104b6fe662 100644 --- a/ext/pgsql/tests/12pg_insert.phpt +++ b/ext/pgsql/tests/12pg_insert.phpt @@ -7,4 +7,5 @@ PostgreSQL pg_insert() include("pg_insert.inc"); ?> --EXPECT-- +INSERT INTO php_pgsql_test (num,str,bin) VALUES (1234,'AAA','BBB'); Ok diff --git a/ext/pgsql/tests/13pg_select.phpt b/ext/pgsql/tests/13pg_select.phpt index 7c61436089..43c94c037f 100644 --- a/ext/pgsql/tests/13pg_select.phpt +++ b/ext/pgsql/tests/13pg_select.phpt @@ -18,4 +18,5 @@ array(1) { string(3) "BBB" } } +SELECT * FROM php_pgsql_test WHERE num=1234; Ok diff --git a/ext/pgsql/tests/14pg_update.phpt b/ext/pgsql/tests/14pg_update.phpt index da78eeac92..7dd4dd2d95 100644 --- a/ext/pgsql/tests/14pg_update.phpt +++ b/ext/pgsql/tests/14pg_update.phpt @@ -7,4 +7,5 @@ PostgreSQL pg_update() include("pg_update.inc"); ?> --EXPECT-- +UPDATE php_pgsql_test SET num=1234,str='ABC',bin='XYZ' WHERE num=1234; Ok diff --git a/ext/pgsql/tests/pg_delete.inc b/ext/pgsql/tests/pg_delete.inc index 33e001081b..33ba80e727 100644 --- a/ext/pgsql/tests/pg_delete.inc +++ b/ext/pgsql/tests/pg_delete.inc @@ -7,7 +7,7 @@ $db = pg_connect($conn_str); $fields = array('num'=>'1234', 'str'=>'XXX', 'bin'=>'YYY'); $ids = array('num'=>'1234'); -if (!pg_delete($db, $table_name, $ids, 1)) { +if (!pg_delete($db, $table_name, $ids)) { echo "Error\n"; } else { diff --git a/ext/pgsql/tests/pg_insert.inc b/ext/pgsql/tests/pg_insert.inc index bfb2e90e83..e0777a215e 100644 --- a/ext/pgsql/tests/pg_insert.inc +++ b/ext/pgsql/tests/pg_insert.inc @@ -4,13 +4,10 @@ error_reporting(E_ALL); include 'config.inc'; $db = pg_connect($conn_str); - $fields = array('num'=>'1234', 'str'=>'AAA', 'bin'=>'BBB'); -if (!pg_insert($db, $table_name, $fields, 1, 0)) { - echo "Error\n"; -} -else { - echo "Ok\n"; -} +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"; ?> diff --git a/ext/pgsql/tests/pg_select.inc b/ext/pgsql/tests/pg_select.inc index 04ca501deb..4d251bc992 100644 --- a/ext/pgsql/tests/pg_select.inc +++ b/ext/pgsql/tests/pg_select.inc @@ -4,15 +4,12 @@ error_reporting(E_ALL); include 'config.inc'; $db = pg_connect($conn_str); - -$fields = array('num'=>'1234', 'str'=>'XXX', 'bin'=>'YYY'); +$fields = array('num'=>'1234', 'str'=>'ABC', 'bin'=>'XYZ'); $ids = array('num'=>'1234'); -if (!($res = pg_select($db, $table_name, $ids, 1))) { - echo "Error\n"; -} -else { - var_dump($res); - echo "Ok\n"; -} + +$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 diff --git a/ext/pgsql/tests/pg_update.inc b/ext/pgsql/tests/pg_update.inc index 6501c09af5..8fc8bb168b 100644 --- a/ext/pgsql/tests/pg_update.inc +++ b/ext/pgsql/tests/pg_update.inc @@ -4,14 +4,12 @@ error_reporting(E_ALL); include 'config.inc'; $db = pg_connect($conn_str); - -$fields = array('num'=>'1234', 'str'=>'XXX', 'bin'=>'YYY'); +$fields = array('num'=>'1234', 'str'=>'ABC', 'bin'=>'XYZ'); $ids = array('num'=>'1234'); -if (!pg_update($db, $table_name, $fields, $ids, 1, 0)) { - echo "Error\n"; -} -else { - echo "Ok\n"; -} + +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"; ?> -- cgit v1.2.1