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