xref: /PHP-7.4/ext/oci8/tests/define4.phpt (revision 26dfce7f)
1--TEST--
2oci_define_by_name() on partial number of columns
3--SKIPIF--
4<?php if (!extension_loaded('oci8')) die("skip no oci8 extension"); ?>
5--FILE--
6<?php
7
8require(__DIR__."/connect.inc");
9
10// Initialize
11
12$stmtarray = array(
13    "drop table define4_tab",
14    "create table define4_tab (value number, string varchar(10))",
15    "insert into define4_tab (value, string) values (1234, 'some')",
16);
17
18oci8_test_sql_execute($c, $stmtarray);
19
20// Run test
21
22$stmt = oci_parse($c, "select value, string from define4_tab");
23
24echo "Test 1\n";
25// Only one of the two columns is defined
26var_dump(oci_define_by_name($stmt, "STRING", $string));
27
28oci_execute($stmt);
29
30echo "Test 2\n";
31
32while (oci_fetch($stmt)) {
33	var_dump(oci_result($stmt, 'VALUE'));
34	var_dump($string);
35	var_dump(oci_result($stmt, 'STRING'));
36	var_dump($string);
37	var_dump(oci_result($stmt, 'VALUE'));
38	var_dump(oci_result($stmt, 'STRING'));
39}
40
41echo "Test 3\n";
42var_dump(oci_free_statement($stmt));
43var_dump($string);
44var_dump(oci_result($stmt, 'STRING'));
45
46// Cleanup
47
48$stmtarray = array(
49    "drop table define4_tab"
50);
51
52oci8_test_sql_execute($c, $stmtarray);
53
54echo "Done\n";
55
56?>
57--EXPECTF--
58Test 1
59bool(true)
60Test 2
61string(4) "1234"
62string(4) "some"
63string(4) "some"
64string(4) "some"
65string(4) "1234"
66string(4) "some"
67Test 3
68bool(true)
69string(4) "some"
70
71Warning: oci_result(): supplied resource is not a valid oci8 statement resource in %s on line %d
72bool(false)
73Done
74