xref: /PHP-8.1/ext/pgsql/tests/pg_update_001.phpt (revision 1f427779)
1--TEST--
2PostgreSQL pg_update() - basic test using schema
3--EXTENSIONS--
4pgsql
5--SKIPIF--
6<?php include("skipif.inc"); ?>
7--FILE--
8<?php
9
10include('config.inc');
11
12$conn = pg_connect($conn_str);
13
14pg_query($conn, 'CREATE SCHEMA phptests');
15
16pg_query($conn, 'CREATE TABLE foo (id INT, id2 INT)');
17pg_query($conn, 'CREATE TABLE phptests.foo (id INT, id2 INT)');
18
19
20pg_insert($conn, 'foo', array('id' => 1, 'id2' => 1));
21pg_insert($conn, 'phptests.foo', array('id' => 1, 'id2' => 2));
22
23pg_update($conn, 'foo', array('id' => 10), array('id' => 1));
24var_dump(pg_update($conn, 'foo', array('id' => 10), array('id' => 1), PGSQL_DML_STRING));
25
26pg_update($conn, 'phptests.foo', array('id' => 100), array('id2' => 2));
27var_dump(pg_update($conn, 'phptests.foo', array('id' => 100), array('id2' => 2), PGSQL_DML_STRING));
28
29$rs = pg_query($conn, 'SELECT * FROM foo UNION SELECT * FROM phptests.foo ORDER BY id');
30while ($row = pg_fetch_assoc($rs)) {
31    var_dump($row);
32}
33
34pg_query($conn, 'DROP TABLE foo');
35pg_query($conn, 'DROP TABLE phptests.foo');
36pg_query($conn, 'DROP SCHEMA phptests');
37
38?>
39--EXPECT--
40string(38) "UPDATE "foo" SET "id"=10 WHERE "id"=1;"
41string(51) "UPDATE "phptests"."foo" SET "id"=100 WHERE "id2"=2;"
42array(2) {
43  ["id"]=>
44  string(2) "10"
45  ["id2"]=>
46  string(1) "1"
47}
48array(2) {
49  ["id"]=>
50  string(3) "100"
51  ["id2"]=>
52  string(1) "2"
53}
54