~ubuntu-branches/ubuntu/lucid/php5/lucid

« back to all changes in this revision

Viewing changes to ext/oci8/tests/edition_1.phpt

  • Committer: Bazaar Package Importer
  • Author(s): Chuck Short
  • Date: 2010-03-16 09:09:50 UTC
  • mfrom: (1.1.18 upstream) (0.3.10 sid)
  • Revision ID: james.westby@ubuntu.com-20100316090950-e36m0pzranoixifd
Tags: 5.3.2-1ubuntu1
* Merge from debian unstable: 
  - debian/control:
    * Dropped firebird2.1-dev, libc-client-dev, libmcrypt-dev as it is in universe.
    * Dropped libmysqlclient15-dev, build against mysql 5.1.
    * Dropped libcurl-dev not in the archive.
    * Suggest php5-suhosin rather than recommends.
    * Dropped php5-imap, php5-interbase, php5-mcrypt since we have versions already in
      universe.
    * Dropped libonig-dev and libqgdbm since its in universe. (will be re-added in lucid+1)
    * Dropped locales-all.
  - modulelist: Drop imap, interbase, and mcrypt.
  - debian/rules:
    * Dropped building of mcrypt, imap, and interbase.
    * Install apport hook for php5.
  - Dropped debian/patches/libedit_is_editline.patch.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
--TEST--
 
2
Basic test for setting Oracle 11gR2 "edition" attribute
 
3
--SKIPIF--
 
4
<?php 
 
5
if (!extension_loaded('oci8')) die("skip no oci8 extension"); 
 
6
require(dirname(__FILE__)."/connect.inc");
 
7
if (strcasecmp($user, "system") && strcasecmp($user, "sys")) 
 
8
    die("skip needs to be run as a DBA user");
 
9
if ($test_drcp) 
 
10
    die("skip as Output might vary with DRCP");
 
11
 
 
12
$sv = oci_server_version($c);
 
13
$sv = preg_match('/Release (11\.2|12)/', $sv, $matches);
 
14
if ($sv == 1) {
 
15
    ob_start();
 
16
    phpinfo(INFO_MODULES);
 
17
    $phpinfo = ob_get_clean();
 
18
    $iv = preg_match('/Oracle .*Version => (11\.2|12)/', $phpinfo);
 
19
    if ($iv != 1) {
 
20
        die ("skip tests a feature that works only with Oracle 11gR2 or greater version of client");
 
21
    }
 
22
}
 
23
else {
 
24
    die ("skip tests a feature that works only with Oracle 11gR2 or greater version of server");
 
25
}
 
26
 
 
27
?>
 
28
--FILE--
 
29
<?php
 
30
 
 
31
/* In 11.2, there can only be one child edition.  So this test will
 
32
 * fail to create the necessary editions if a child edition exists
 
33
 * already 
 
34
 */
 
35
 
 
36
require(dirname(__FILE__)."/conn_attr.inc");
 
37
 
 
38
function select_fn($conn) {
 
39
        $s = oci_parse($conn,"select * from view_ed");
 
40
        oci_execute($s);
 
41
        while ($row = oci_fetch_row($s)) {
 
42
                var_dump($row);
 
43
        }
 
44
}
 
45
/* Create a editon MYEDITION 
 
46
   create a view view_ed in MYEDITION1.
 
47
   create the same view 'view_ed' with a different definition in MYEDITION.
 
48
   select from both the editions and verify the contents. */
 
49
 
 
50
set_edit_attr('MYEDITION');
 
51
$conn = oci_connect('testuser','testuser',$dbase); 
 
52
if ($conn === false) {
 
53
    $m = oci_error();
 
54
    die("Error:" . $m['message']);
 
55
}
 
56
    
 
57
$stmtarray = array(
 
58
    "drop table edit_tab",
 
59
    "create table edit_tab (name varchar2(10),age number,job varchar2(50), salary number)",
 
60
    "insert into edit_tab values('mike',30,'Senior engineer',200)",
 
61
    "insert into edit_tab values('juan',25,'engineer',100)",
 
62
    "create or replace editioning view view_ed as select name,age,job from edit_tab",
 
63
);
 
64
 
 
65
foreach ($stmtarray as $stmt) {
 
66
    $s = oci_parse($conn, $stmt);
 
67
    @oci_execute($s);
 
68
}
 
69
 
 
70
// Check the current edition of the DB and the contents of view_ed.
 
71
get_edit_attr($conn);
 
72
select_fn($conn);
 
73
 
 
74
// Create a different version of view_ed in MYEDITION1.
 
75
set_edit_attr('MYEDITION1');
 
76
$conn2 = oci_new_connect('testuser','testuser',$dbase); 
 
77
$stmt = "create or replace editioning view view_ed as select name,age,job,salary from edit_tab";
 
78
$s = oci_parse($conn2, $stmt);
 
79
oci_execute($s);
 
80
 
 
81
// Check the current edition of the DB and the contents of view_ed.
 
82
get_edit_attr($conn2);
 
83
select_fn($conn2);
 
84
 
 
85
// Verify the contents in MYEDITION EDITION.
 
86
echo "version of view_ed in MYEDITION \n";
 
87
get_edit_attr($conn);
 
88
select_fn($conn);
 
89
 
 
90
clean_up($c);
 
91
 
 
92
oci_close($conn);
 
93
oci_close($conn2);
 
94
echo "Done\n";
 
95
 
 
96
?>
 
97
--EXPECTF--
 
98
The value of edition has been successfully set
 
99
The value of current EDITION is MYEDITION
 
100
array(3) {
 
101
  [0]=>
 
102
  %unicode|string%(%d) "mike"
 
103
  [1]=>
 
104
  %unicode|string%(%d) "30"
 
105
  [2]=>
 
106
  %unicode|string%(%d) "Senior engineer"
 
107
}
 
108
array(3) {
 
109
  [0]=>
 
110
  %unicode|string%(%d) "juan"
 
111
  [1]=>
 
112
  %unicode|string%(%d) "25"
 
113
  [2]=>
 
114
  %unicode|string%(%d) "engineer"
 
115
}
 
116
 The value of edition has been successfully set
 
117
The value of current EDITION is MYEDITION1
 
118
array(4) {
 
119
  [0]=>
 
120
  %unicode|string%(%d) "mike"
 
121
  [1]=>
 
122
  %unicode|string%(%d) "30"
 
123
  [2]=>
 
124
  %unicode|string%(%d) "Senior engineer"
 
125
  [3]=>
 
126
  %unicode|string%(%d) "200"
 
127
}
 
128
array(4) {
 
129
  [0]=>
 
130
  %unicode|string%(%d) "juan"
 
131
  [1]=>
 
132
  %unicode|string%(%d) "25"
 
133
  [2]=>
 
134
  %unicode|string%(%d) "engineer"
 
135
  [3]=>
 
136
  %unicode|string%(%d) "100"
 
137
}
 
138
version of view_ed in MYEDITION 
 
139
The value of current EDITION is MYEDITION
 
140
array(3) {
 
141
  [0]=>
 
142
  %unicode|string%(%d) "mike"
 
143
  [1]=>
 
144
  %unicode|string%(%d) "30"
 
145
  [2]=>
 
146
  %unicode|string%(%d) "Senior engineer"
 
147
}
 
148
array(3) {
 
149
  [0]=>
 
150
  %unicode|string%(%d) "juan"
 
151
  [1]=>
 
152
  %unicode|string%(%d) "25"
 
153
  [2]=>
 
154
  %unicode|string%(%d) "engineer"
 
155
}
 
156
Done