xref: /PHP-8.0/ext/oci8/tests/define1.phpt (revision 4173f2b3)
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 define1_tab",
14    "create table define1_tab (string varchar(10))",
15    "insert into define1_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 define1_tab");
23
24/* the define MUST be done BEFORE ociexecute! */
25
26$string = '';
27var_dump(oci_define_by_name($stmt, "STRING", $string, 20));
28var_dump(oci_define_by_name($stmt, "STRING", $string, 20));
29try {
30    var_dump(oci_define_by_name($stmt, "", $string, 20));
31} catch (ValueError $e) {
32    echo $e->getMessage(), "\n";
33}
34
35oci_execute($stmt);
36
37while (oci_fetch($stmt)) {
38    var_dump($string);
39}
40
41// Cleanup
42
43$stmtarray = array(
44    "drop table define1_tab"
45);
46
47oci8_test_sql_execute($c, $stmtarray);
48
49echo "Done\n";
50
51?>
52--EXPECTF--
53bool(true)
54bool(false)
55oci_define_by_name(): Argument #2 ($column) cannot be empty
56string(4) "some"
57Done
58