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