xref: /PHP-8.4/ext/pgsql/tests/pg_insert_001.phpt (revision c15988aa)
1--TEST--
2PostgreSQL pg_select() - basic test using schema
3--EXTENSIONS--
4pgsql
5--SKIPIF--
6<?php include("inc/skipif.inc"); ?>
7--FILE--
8<?php
9
10include('inc/config.inc');
11$schema_name = 'schema_pg_insert_001';
12$table_name = 'table_pg_insert_001';
13
14$conn = pg_connect($conn_str);
15
16pg_query($conn, "CREATE SCHEMA {$schema_name}");
17pg_query($conn, "CREATE TABLE {$schema_name}.{$table_name} (id INT, id2 INT)");
18
19
20pg_insert($conn, $table_name, array('id' => 1, 'id2' => 1));
21
22pg_insert($conn, "{$schema_name}.{$table_name}", array('id' => 1, 'id2' => 2));
23
24var_dump(pg_insert($conn, "{$schema_name}.{$table_name}", array('id' => 1, 'id2' => 2), PGSQL_DML_STRING));
25
26var_dump(pg_select($conn, "{$schema_name}.{$table_name}", array('id' => 1)));
27
28?>
29--CLEAN--
30<?php
31require_once('inc/config.inc');
32$schema_name = 'schema_pg_insert_001';
33$table_name = 'table_pg_insert_001';
34
35$conn = pg_connect($conn_str);
36pg_query($conn, "DROP TABLE IF EXISTS {$schema_name}.{$table_name}");
37pg_query($conn, "DROP SCHEMA IF EXISTS {$schema_name}");
38?>
39--EXPECTF--
40Warning: pg_insert(): Table 'table_pg_insert_001' doesn't exists in %s on line %d
41string(83) "INSERT INTO "schema_pg_insert_001"."table_pg_insert_001" ("id","id2") VALUES (1,2);"
42array(1) {
43  [0]=>
44  array(2) {
45    ["id"]=>
46    string(1) "1"
47    ["id2"]=>
48    string(1) "2"
49  }
50}
51