xref: /PHP-8.0/ext/oci8/tests/define0.phpt (revision f8d79582)
1--TEST--
2oci_define_by_name()
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 define0_tab",
14    "create table define0_tab (string varchar(10))",
15    "insert into define0_tab (string) values ('some')",
16);
17
18oci8_test_sql_execute($c, $stmtarray);
19
20// Run test
21
22$stmt = oci_parse($c, "select string from define0_tab");
23
24/* the define MUST be done BEFORE ociexecute! */
25
26echo "Test 1\n";
27
28$string = '';
29oci_define_by_name($stmt, "STRING", $string, 20);
30oci_execute($stmt);
31while (oci_fetch($stmt)) {
32    var_dump($string);
33}
34
35echo "Test 2\n";
36
37$string = '';
38$s2 = oci_parse($c, 'select string from define0_tab');
39oci_define_by_name($s2, 'STRING', $string);
40oci_execute($s2);
41while (oci_fetch($s2)) {
42    var_dump($string);
43}
44
45// Cleanup
46
47$stmtarray = array(
48    "drop table define0_tab"
49);
50
51oci8_test_sql_execute($c, $stmtarray);
52
53?>
54--EXPECTF--
55Test 1
56string(%d) "some"
57Test 2
58string(%d) "some"
59