1--TEST-- 2PostgreSQL pg_delete() - 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 19pg_insert($conn, 'foo', array('id' => 1, 'id2' => 1)); 20pg_insert($conn, 'foo', array('id' => 1, 'id2' => 2)); 21pg_insert($conn, 'foo', array('id' => 1, 'id2' => 2)); 22pg_insert($conn, 'foo', array('id' => 3, 'id2' => 3)); 23 24pg_insert($conn, 'phptests.foo', array('id' => 1, 'id2' => 1)); 25pg_insert($conn, 'phptests.foo', array('id' => 1, 'id2' => 2)); 26pg_insert($conn, 'phptests.foo', array('id' => 2, 'id2' => 3)); 27pg_insert($conn, 'phptests.foo', array('id' => 2, 'id2' => 3)); 28 29pg_delete($conn, 'foo', array('id' => 1, 'id2' => 0)); 30pg_delete($conn, 'foo', array('id' => 1, 'id2' => 2)); 31var_dump(pg_delete($conn, 'foo', array('id' => 1, 'id2' => 2), PGSQL_DML_STRING)); 32 33pg_delete($conn, 'phptests.foo', array('id' => 2, 'id2' => 1)); 34pg_delete($conn, 'phptests.foo', array('id' => 2, 'id2' => 3)); 35var_dump(pg_delete($conn, 'phptests.foo', array('id' => 2, 'id2' => 3), PGSQL_DML_STRING)); 36 37var_dump(pg_fetch_all(pg_query($conn, 'SELECT * FROM foo'))); 38var_dump(pg_fetch_all(pg_query($conn, 'SELECT * FROM phptests.foo'))); 39 40/* Inexistent */ 41pg_delete($conn, 'bar', array('id' => 1, 'id2' => 2)); 42var_dump(pg_delete($conn, 'bar', array('id' => 1, 'id2' => 2), PGSQL_DML_STRING)); 43 44pg_query($conn, 'DROP TABLE foo'); 45pg_query($conn, 'DROP TABLE phptests.foo'); 46pg_query($conn, 'DROP SCHEMA phptests'); 47 48?> 49--EXPECTF-- 50string(43) "DELETE FROM "foo" WHERE "id"=1 AND "id2"=2;" 51string(54) "DELETE FROM "phptests"."foo" WHERE "id"=2 AND "id2"=3;" 52array(2) { 53 [0]=> 54 array(2) { 55 ["id"]=> 56 string(1) "1" 57 ["id2"]=> 58 string(1) "1" 59 } 60 [1]=> 61 array(2) { 62 ["id"]=> 63 string(1) "3" 64 ["id2"]=> 65 string(1) "3" 66 } 67} 68array(2) { 69 [0]=> 70 array(2) { 71 ["id"]=> 72 string(1) "1" 73 ["id2"]=> 74 string(1) "1" 75 } 76 [1]=> 77 array(2) { 78 ["id"]=> 79 string(1) "1" 80 ["id2"]=> 81 string(1) "2" 82 } 83} 84 85Warning: pg_delete(): Table 'bar' doesn't exists in %s on line %d 86 87Warning: pg_delete(): Table 'bar' doesn't exists in %s on line %d 88bool(false) 89