xref: /PHP-7.2/ext/oci8/tests/bind_query.phpt (revision bdd67d81)
1--TEST--
2Bind with various WHERE conditions
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// Initialization
11
12$stmtarray = array(
13	"drop table bind_query_tab",
14	"create table bind_query_tab (empno number(4), ename varchar2(10), sal number(7,2))",
15	"insert into bind_query_tab values (7934, 'MILLER', 1300)",
16	"insert into bind_query_tab values (7902, 'FORD', 3000)"
17);
18
19oci8_test_sql_execute($c, $stmtarray);
20
21// Run Test
22
23echo "Test 1\n";
24
25$e = 7934;
26
27$s = oci_parse($c, "select ename from bind_query_tab where empno = :eno");
28oci_bind_by_name( $s, ":eno", $e, -1, SQLT_INT);
29oci_execute($s);
30var_dump(oci_fetch_row($s));
31
32echo "Test 2\n";
33
34$v = 1000;
35$s = oci_parse($c, 'select ename from bind_query_tab where sal > :v order by ename');
36oci_bind_by_name( $s, ":v", $v);
37oci_define_by_name($s, "ENAME", $ename, 20);
38oci_execute($s);
39while (oci_fetch($s)) {
40    var_dump($ename);
41}
42
43
44echo "Test 3\n";
45
46$s = oci_parse($c, 'select ename from bind_query_tab where sal > :v order by ename');
47oci_bind_by_name( $s, ":v", $v);
48$v = 2000;
49oci_define_by_name($s, "ENAME", $ename, 20);
50oci_execute($s);
51while (oci_fetch($s)) {
52    var_dump($ename);
53}
54
55
56// Clean up
57
58$stmtarray = array(
59	"drop table bind_query_tab"
60);
61
62oci8_test_sql_execute($c, $stmtarray);
63
64?>
65===DONE===
66<?php exit(0); ?>
67--EXPECT--
68Test 1
69array(1) {
70  [0]=>
71  string(6) "MILLER"
72}
73Test 2
74string(4) "FORD"
75string(6) "MILLER"
76Test 3
77string(4) "FORD"
78===DONE===
79