xref: /PHP-8.2/ext/pgsql/tests/pg_insert_001.phpt (revision 1f427779)
1--TEST--
2PostgreSQL pg_select() - 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');
15pg_query($conn, 'CREATE TABLE phptests.foo (id INT, id2 INT)');
16
17
18pg_insert($conn, 'foo', array('id' => 1, 'id2' => 1));
19
20pg_insert($conn, 'phptests.foo', array('id' => 1, 'id2' => 2));
21
22var_dump(pg_insert($conn, 'phptests.foo', array('id' => 1, 'id2' => 2), PGSQL_DML_STRING));
23
24var_dump(pg_select($conn, 'phptests.foo', array('id' => 1)));
25
26pg_query($conn, 'DROP TABLE phptests.foo');
27pg_query($conn, 'DROP SCHEMA phptests');
28
29?>
30--EXPECTF--
31Warning: pg_insert(): Table 'foo' doesn't exists in %s on line %d
32string(55) "INSERT INTO "phptests"."foo" ("id","id2") VALUES (1,2);"
33array(1) {
34  [0]=>
35  array(2) {
36    ["id"]=>
37    string(1) "1"
38    ["id2"]=>
39    string(1) "2"
40  }
41}
42