xref: /PHP-8.2/ext/oci8/tests/error_bind_2.phpt (revision 72f47c0c)
1--TEST--
2Test some more oci_bind_by_name error conditions
3--EXTENSIONS--
4oci8
5--SKIPIF--
6<?php
7$target_dbs = array('oracledb' => true, 'timesten' => true);  // test runs on these DBs
8require(__DIR__.'/skipif.inc');
9preg_match('/.*Release ([[:digit:]]+)\.([[:digit:]]+)\.([[:digit:]]+)\.([[:digit:]]+)\.([[:digit:]]+)*/', oci_server_version($c), $matches);
10if (!(isset($matches[0]) && $matches[1] >= 12)) {
11    die("skip expected output only valid when using Oracle Database 12c or greater");
12}
13preg_match('/^[[:digit:]]+/', oci_client_version(), $matches);
14if (!(isset($matches[0]) && $matches[0] >= 12)) {
15    die("skip works only with Oracle 12c or greater version of Oracle client libraries");
16}
17?>
18--FILE--
19<?php
20
21require(__DIR__.'/connect.inc');
22
23// Initialization
24
25$stmtarray = array(
26    "drop table error_bind_2_tab",
27    "create table error_bind_2_tab(name varchar(10))"
28);
29oci8_test_sql_execute($c, $stmtarray);
30
31echo "Test 1 - SQLT_BOL\n";
32
33unset($name);
34$stmt = oci_parse($c, "insert into error_bind_2_tab values (:name)");
35oci_bind_by_name($stmt, ":name", $name, -1, SQLT_BOL);
36$name=$c;
37var_dump(oci_execute($stmt));
38
39echo "Test 2 - SQLT_BOL\n";
40
41unset($name);
42$stmt = oci_parse($c, "insert into error_bind_2_tab values (:name)");
43$name=$c;
44oci_bind_by_name($stmt, ":name", $name, -1, SQLT_BOL);
45
46// Clean up
47
48$stmtarray = array(
49    "drop table error_bind_2_tab",
50);
51oci8_test_sql_execute($c, $stmtarray);
52
53echo "Done\n";
54
55?>
56--EXPECTF--
57Test 1 - SQLT_BOL
58
59Warning: oci_execute(): Invalid variable used for bind in %s on line %d
60bool(false)
61Test 2 - SQLT_BOL
62
63Warning: oci_bind_by_name(): Invalid variable used for bind in %s on line %d
64Done
65