xref: /PHP-8.1/ext/oci8/tests/error_bind.phpt (revision 74859783)
1--TEST--
2Test some oci_bind_by_name error conditions
3--EXTENSIONS--
4oci8
5--FILE--
6<?php
7
8require(__DIR__.'/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);
16oci_execute($statement);
17
18
19echo "Insert value\n";
20
21$name = 'abc';
22$stmt = oci_parse($c, "insert into bind_test values (:name)");
23oci_bind_by_name($stmt, ":name", $name, 10, SQLT_CHR);
24var_dump(oci_execute($stmt));
25
26echo "Test 1 - Assign a resource to the bind variable and execute\n";
27$name=$c;
28var_dump(oci_execute($stmt));
29
30echo "Test 2 - Re-bind a resource\n";
31oci_bind_by_name($stmt, ":name", $c);
32var_dump(oci_execute($stmt));
33var_dump($c);
34
35// Use a connection resource instead of a ROWID.
36echo "Test 3 - Resource mismatch !!\n";
37$stmt = oci_parse($c, "update bind_test set name='xyz' returning rowid into :r_id");
38oci_bind_by_name($stmt, ":r_id", $c);
39var_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
47echo "Done\n";
48
49?>
50--EXPECTF--
51Insert value
52bool(true)
53Test 1 - Assign a resource to the bind variable and execute
54
55Warning: oci_execute(): Invalid variable used for bind in %s on line %d
56bool(false)
57Test 2 - Re-bind a resource
58
59Warning: oci_bind_by_name(): Invalid variable used for bind in %s on line %d
60
61Warning: oci_execute(): Invalid variable used for bind in %s on line %d
62bool(false)
63resource(%d) of type (oci8 connection)
64Test 3 - Resource mismatch !!
65
66Warning: oci_bind_by_name(): Invalid variable used for bind in %s on line %d
67
68Warning: oci_execute(): ORA-%r(01008|57000)%r: %s on line %d
69bool(false)
70Done
71