xref: /PHP-5.6/ext/oci8/tests/define1.phpt (revision bfc3c223)
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(dirname(__FILE__)."/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));
29var_dump(oci_define_by_name($stmt, "", $string, 20));
30var_dump(oci_define_by_name($stmt, ""));
31
32oci_execute($stmt);
33
34while (oci_fetch($stmt)) {
35	var_dump($string);
36}
37
38// Cleanup
39
40$stmtarray = array(
41    "drop table define1_tab"
42);
43
44oci8_test_sql_execute($c, $stmtarray);
45
46echo "Done\n";
47
48?>
49--EXPECTF--
50bool(true)
51bool(false)
52
53Warning: oci_define_by_name(): Column name cannot be empty in %s on line %d
54bool(false)
55
56Warning: oci_define_by_name() expects at least 3 parameters, 2 given in %s on line %d
57NULL
58string(4) "some"
59Done
60