xref: /PHP-8.0/ext/oci8/tests/null_byte_2.phpt (revision a555cc0b)
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(__DIR__.'/skipif.inc');
7?>
8--INI--
9display_errors = On
10error_reporting = E_WARNING
11--FILE--
12<?php
13
14require(__DIR__.'/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--EXPECTF--
35Test 1: Valid use of a null byte
36array(1) {
37  ["DUMMY"]=>
38  array(1) {
39    [0]=>
40    string(1) "X"
41  }
42}
43Test 3: Using a null byte in a bind variable name
44
45Warning: oci_bind_by_name(): ORA-01036: %s in %snull_byte_2.php on line %d
46
47Warning: oci_execute(): ORA-01008: %s in %snull_byte_2.php on line %d
48