Annotation of embedaddon/php/ext/oci8/tests/error_bind.phpt, revision 1.1.1.1
1.1 misho 1: --TEST--
2: Test some oci_bind_by_name error conditions
3: --SKIPIF--
4: <?php if (!extension_loaded('oci8')) die("skip no oci8 extension"); ?>
5: --FILE--
6: <?php
7:
8: require(dirname(__FILE__).'/connect.inc');
9:
10: $drop = "drop table bind_test";
11: $statement = oci_parse($c, $drop);
12: @oci_execute($statement);
13:
14: $create = "create table bind_test(name varchar(10))";
15: $statement = oci_parse($c, $create);
16: oci_execute($statement);
17:
18:
19: echo "Insert value\n";
20:
21: $name = 'abc';
22: $stmt = oci_parse($c, "insert into bind_test values (:name)");
23: oci_bind_by_name($stmt, ":name", $name, 10, SQLT_CHR);
24: var_dump(oci_execute($stmt));
25:
26: echo "Test 1 - Assign a resource to the bind variable and execute \n";
27: $name=$c;
28: var_dump(oci_execute($stmt));
29:
30: echo "Test 2 - Re-bind a resource\n";
31: oci_bind_by_name($stmt, ":name", $c);
32: var_dump(oci_execute($stmt));
33: var_dump($c);
34:
35: // Use a connection resource instead of a ROWID.
36: echo "Test 3 - Resource mismatch !!\n";
37: $stmt = oci_parse($c, "update bind_test set name='xyz' returning rowid into :r_id");
38: oci_bind_by_name($stmt, ":r_id", $c);
39: var_dump(oci_execute($stmt));
40:
41: // Clean up
42:
43: $drop = "drop table bind_test";
44: $statement = oci_parse($c, $drop);
45: @oci_execute($statement);
46:
47: echo "Done\n";
48:
49: ?>
50: --EXPECTF--
51: Insert value
52: bool(true)
53: Test 1 - Assign a resource to the bind variable and execute
54:
55: Warning: oci_execute(): Invalid variable used for bind in %s on line %d
56: bool(false)
57: Test 2 - Re-bind a resource
58:
59: Warning: oci_bind_by_name(): Invalid variable used for bind in %s on line %d
60:
61: Warning: oci_execute(): Invalid variable used for bind in %s on line %d
62: bool(false)
63: resource(%d) of type (oci8 connection)
64: Test 3 - Resource mismatch !!
65:
66: Warning: oci_bind_by_name(): Invalid variable used for bind in %s on line %d
67:
68: Warning: oci_execute(): ORA-%r(01008|57000)%r: %s on line %d
69: bool(false)
70: Done
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>