xref: /php-src/ext/pgsql/tests/14pg_update_9.phpt (revision c15988aa)
1--TEST--
2PostgreSQL pg_update() (9.0+)
3--EXTENSIONS--
4pgsql
5--SKIPIF--
6<?php
7include("inc/skipif.inc");
8skip_bytea_not_hex();
9?>
10--FILE--
11<?php
12error_reporting(E_ALL);
13
14include 'inc/config.inc';
15$table_name = "table_14pg_update_9";
16
17$db = pg_connect($conn_str);
18pg_query($db, "CREATE TABLE {$table_name} (num int, str text, bin bytea)");
19pg_query($db, "INSERT INTO {$table_name} VALUES(1, 'ABC', null)");
20pg_query($db, "INSERT INTO {$table_name} VALUES(1, 'ABC', null)");
21
22pg_query($db, "SET standard_conforming_strings = 0");
23
24$fields = array('num'=>'1234', 'str'=>'ABC', 'bin'=>'XYZ');
25$ids = array('num'=>'1234');
26
27pg_update($db, $table_name, $fields, $ids) or print "Error in test 1\n";
28echo pg_update($db, $table_name, $fields, $ids, PGSQL_DML_STRING)."\n";
29echo pg_update($db, $table_name, $fields, $ids, PGSQL_DML_STRING|PGSQL_DML_ESCAPE)."\n";
30
31echo "Ok\n";
32?>
33--CLEAN--
34<?php
35include('inc/config.inc');
36$table_name = "table_14pg_update_9";
37
38$db = pg_connect($conn_str);
39pg_query($db, "DROP TABLE IF EXISTS {$table_name}");
40?>
41--EXPECT--
42UPDATE "table_14pg_update_9" SET "num"=1234,"str"=E'ABC',"bin"=E'\\x58595a' WHERE "num"=1234;
43UPDATE "table_14pg_update_9" SET "num"='1234',"str"='ABC',"bin"='XYZ' WHERE "num"='1234';
44Ok
45