xref: /PHP-8.3/ext/oci8/tests/define0.phpt (revision a53e5617)
1--TEST--
2oci_define_by_name()
3--EXTENSIONS--
4oci8
5--SKIPIF--
6<?php
7require_once 'skipifconnectfailure.inc';
8?>
9--FILE--
10<?php
11
12require __DIR__.'/connect.inc';
13
14// Initialize
15
16$stmtarray = array(
17    "drop table define0_tab",
18    "create table define0_tab (string varchar(10))",
19    "insert into define0_tab (string) values ('some')",
20);
21
22oci8_test_sql_execute($c, $stmtarray);
23
24// Run test
25
26$stmt = oci_parse($c, "select string from define0_tab");
27
28/* the define MUST be done BEFORE ociexecute! */
29
30echo "Test 1\n";
31
32$string = '';
33oci_define_by_name($stmt, "STRING", $string, 20);
34oci_execute($stmt);
35while (oci_fetch($stmt)) {
36    var_dump($string);
37}
38
39echo "Test 2\n";
40
41$string = '';
42$s2 = oci_parse($c, 'select string from define0_tab');
43oci_define_by_name($s2, 'STRING', $string);
44oci_execute($s2);
45while (oci_fetch($s2)) {
46    var_dump($string);
47}
48
49// Cleanup
50
51$stmtarray = array(
52    "drop table define0_tab"
53);
54
55oci8_test_sql_execute($c, $stmtarray);
56
57?>
58--EXPECTF--
59Test 1
60string(%d) "some"
61Test 2
62string(%d) "some"
63