xref: /PHP-8.4/ext/pgsql/tests/15pg_delete.phpt (revision c15988aa)
1--TEST--
2PostgreSQL pg_delete()
3--EXTENSIONS--
4pgsql
5--SKIPIF--
6<?php include("inc/skipif.inc"); ?>
7--FILE--
8<?php
9error_reporting(E_ALL);
10
11include 'inc/config.inc';
12$table_name = "table_15pg_delete";
13
14$db = pg_connect($conn_str);
15pg_query($db, "CREATE TABLE {$table_name} (num int, str text, bin bytea)");
16pg_query($db, "INSERT INTO {$table_name} VALUES(1, 'ABC', null)");
17pg_query($db, "INSERT INTO {$table_name} VALUES(1, 'ABC', null)");
18
19$fields = array('num'=>'1234', 'str'=>'XXX', 'bin'=>'YYY');
20$ids = array('num'=>'1234');
21echo pg_delete($db, $table_name, $ids, PGSQL_DML_STRING)."\n";
22echo pg_delete($db, $table_name, $ids, PGSQL_DML_STRING|PGSQL_DML_ESCAPE)."\n";
23if (!pg_delete($db, $table_name, $ids)) {
24    echo "Error\n";
25}
26else {
27    echo "Ok\n";
28}
29?>
30--CLEAN--
31<?php
32include('inc/config.inc');
33$table_name = "table_15pg_delete";
34
35$db = pg_connect($conn_str);
36pg_query($db, "DROP TABLE IF EXISTS {$table_name}");
37?>
38--EXPECT--
39DELETE FROM "table_15pg_delete" WHERE "num"=1234;
40DELETE FROM "table_15pg_delete" WHERE "num"='1234';
41Ok
42