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