2
Test some oci_bind_by_name error conditions
4
<?php if (!extension_loaded('oci8')) die("skip no oci8 extension"); ?>
8
require(dirname(__FILE__).'/connect.inc');
10
$drop = "drop table bind_test";
11
$statement = oci_parse($c, $drop);
12
@oci_execute($statement);
14
$create = "create table bind_test(name varchar(10))";
15
$statement = oci_parse($c, $create);
16
oci_execute($statement);
19
echo "Insert value\n";
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));
26
echo "Test 1 - Assign a resource to the bind variable and execute \n";
28
var_dump(oci_execute($stmt));
30
echo "Test 2 - Re-bind a resource\n";
31
oci_bind_by_name($stmt, ":name", $c);
32
var_dump(oci_execute($stmt));
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));
43
$drop = "drop table bind_test";
44
$statement = oci_parse($c, $drop);
45
@oci_execute($statement);
53
Test 1 - Assign a resource to the bind variable and execute
55
Warning: oci_execute(): Invalid variable used for bind in %s on line %d
57
Test 2 - Re-bind a resource
59
Warning: oci_bind_by_name(): Invalid variable used for bind in %s on line %d
61
Warning: oci_execute(): Invalid variable used for bind in %s on line %d
63
resource(%d) of type (oci8 connection)
64
Test 3 - Resource mismatch !!
66
Warning: oci_bind_by_name(): Invalid variable used for bind in %s on line %d
68
Warning: oci_execute(): ORA-01008: %s on line %d