xref: /PHP-7.0/ext/oci8/tests/null_byte_2.phpt (revision c7a8bd6a)
1--TEST--
2Null bytes in SQL statements
3--SKIPIF--
4<?php
5$target_dbs = array('oracledb' => true, 'timesten' => false);  // test runs on these DBs
6require(dirname(__FILE__).'/skipif.inc');
7?>
8--INI--
9display_errors = On
10error_reporting = E_WARNING
11--FILE--
12<?php
13
14require(dirname(__FILE__).'/connect.inc');
15
16// Run Test
17
18echo "Test 1: Valid use of a null byte\n";
19
20$s = oci_parse($c, "select * \0from dual");
21oci_execute($s);
22oci_fetch_all($s, $res);
23var_dump($res);
24
25echo "Test 3: Using a null byte in a bind variable name\n";
26
27$s = oci_parse($c, "select * from dual where :bv = 1");
28$bv = 1;
29oci_bind_by_name($s, ":bv\0:bv", $bv);
30oci_execute($s);
31
32
33?>
34===DONE===
35<?php exit(0); ?>
36--EXPECTF--
37Test 1: Valid use of a null byte
38array(1) {
39  ["DUMMY"]=>
40  array(1) {
41    [0]=>
42    string(1) "X"
43  }
44}
45Test 3: Using a null byte in a bind variable name
46
47Warning: oci_bind_by_name(): ORA-01036: %s in %snull_byte_2.php on line %d
48
49Warning: oci_execute(): ORA-01008: %s in %snull_byte_2.php on line %d
50===DONE===
51