Annotation of embedaddon/php/ext/pgsql/tests/pg_delete_001.phpt, revision 1.1.1.1
1.1 misho 1: --TEST--
2: PostgreSQL pg_delete() - basic test using schema
3: --SKIPIF--
4: <?php include("skipif.inc"); ?>
5: --FILE--
6: <?php
7:
8: include('config.inc');
9:
10: $conn = pg_connect($conn_str);
11:
12: pg_query('CREATE SCHEMA phptests');
13:
14: pg_query('CREATE TABLE foo (id INT, id2 INT)');
15: pg_query('CREATE TABLE phptests.foo (id INT, id2 INT)');
16:
17: pg_insert($conn, 'foo', array('id' => 1, 'id2' => 1));
18: pg_insert($conn, 'foo', array('id' => 1, 'id2' => 2));
19: pg_insert($conn, 'foo', array('id' => 1, 'id2' => 2));
20: pg_insert($conn, 'foo', array('id' => 3, 'id2' => 3));
21:
22: pg_insert($conn, 'phptests.foo', array('id' => 1, 'id2' => 1));
23: pg_insert($conn, 'phptests.foo', array('id' => 1, 'id2' => 2));
24: pg_insert($conn, 'phptests.foo', array('id' => 2, 'id2' => 3));
25: pg_insert($conn, 'phptests.foo', array('id' => 2, 'id2' => 3));
26:
27: pg_delete($conn, 'foo', array('id' => 1, 'id2' => 0));
28: pg_delete($conn, 'foo', array('id' => 1, 'id2' => 2));
29: var_dump(pg_delete($conn, 'foo', array('id' => 1, 'id2' => 2), PGSQL_DML_STRING));
30:
31: pg_delete($conn, 'phptests.foo', array('id' => 2, 'id2' => 1));
32: pg_delete($conn, 'phptests.foo', array('id' => 2, 'id2' => 3));
33: var_dump(pg_delete($conn, 'phptests.foo', array('id' => 2, 'id2' => 3), PGSQL_DML_STRING));
34:
35: var_dump(pg_fetch_all(pg_query('SELECT * FROM foo')));
36: var_dump(pg_fetch_all(pg_query('SELECT * FROM phptests.foo')));
37:
38: /* Inexistent */
39: pg_delete($conn, 'bar', array('id' => 1, 'id2' => 2));
40: var_dump(pg_delete($conn, 'bar', array('id' => 1, 'id2' => 2), PGSQL_DML_STRING));
41:
42: pg_query('DROP TABLE foo');
43: pg_query('DROP TABLE phptests.foo');
44: pg_query('DROP SCHEMA phptests');
45:
46: ?>
47: --EXPECTF--
48: string(37) "DELETE FROM foo WHERE id=1 AND id2=2;"
49: string(46) "DELETE FROM phptests.foo WHERE id=2 AND id2=3;"
50: array(2) {
51: [0]=>
52: array(2) {
53: ["id"]=>
54: string(1) "1"
55: ["id2"]=>
56: string(1) "1"
57: }
58: [1]=>
59: array(2) {
60: ["id"]=>
61: string(1) "3"
62: ["id2"]=>
63: string(1) "3"
64: }
65: }
66: array(2) {
67: [0]=>
68: array(2) {
69: ["id"]=>
70: string(1) "1"
71: ["id2"]=>
72: string(1) "1"
73: }
74: [1]=>
75: array(2) {
76: ["id"]=>
77: string(1) "1"
78: ["id2"]=>
79: string(1) "2"
80: }
81: }
82:
83: Warning: pg_delete(): Table 'bar' doesn't exists in %s on line %d
84:
85: Warning: pg_delete(): Table 'bar' doesn't exists in %s on line %d
86: bool(false)
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>