summaryrefslogtreecommitdiff
path: root/tests/error_bind.phpt
blob: ad66ad59fee73ff1b48489452c4e9bbf7527f9c8 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
--TEST--
Test some oci_bind_by_name error conditions
--SKIPIF--
<?php if (!extension_loaded('oci8')) die("skip no oci8 extension"); ?>
--FILE--
<?php

require(dirname(__FILE__).'/connect.inc');

$drop = "drop table bind_test";
$statement = oci_parse($c, $drop);
@oci_execute($statement);

$create = "create table bind_test(name varchar(10))";
$statement = oci_parse($c, $create);
oci_execute($statement);


echo "Insert value\n";

$name = 'abc';
$stmt = oci_parse($c, "insert into bind_test values (:name)");
oci_bind_by_name($stmt, ":name", $name, 10, SQLT_CHR);
var_dump(oci_execute($stmt));

echo "Test 1 - Assign a resource to the bind variable and execute \n";
$name=$c;
var_dump(oci_execute($stmt));

echo "Test 2 - Re-bind a resource\n";
oci_bind_by_name($stmt, ":name", $c);
var_dump(oci_execute($stmt));
var_dump($c);

// Use a connection resource instead of a ROWID.
echo "Test 3 - Resource mismatch !!\n";
$stmt = oci_parse($c, "update bind_test set name='xyz' returning rowid into :r_id");
oci_bind_by_name($stmt, ":r_id", $c);
var_dump(oci_execute($stmt));

// Clean up

$drop = "drop table bind_test";
$statement = oci_parse($c, $drop);
@oci_execute($statement);

echo "Done\n";

?>
--EXPECTF--
Insert value
bool(true)
Test 1 - Assign a resource to the bind variable and execute 

Warning: oci_execute(): Invalid variable used for bind in %s on line %d
bool(false)
Test 2 - Re-bind a resource

Warning: oci_bind_by_name(): Invalid variable used for bind in %s on line %d

Warning: oci_execute(): Invalid variable used for bind in %s on line %d
bool(false)
resource(%d) of type (oci8 connection)
Test 3 - Resource mismatch !!

Warning: oci_bind_by_name(): Invalid variable used for bind in %s on line %d

Warning: oci_execute(): ORA-01008: %s on line %d
bool(false)
Done