reference/oci8/functions/oci-new-connect.xml
ed6de1ae20ce16c0c7be0b3fef282b6065bebfac
...
...
@@ -9,12 +9,12 @@
9
9
<refsect1 role="description">
10
10
&reftitle.description;
11
11
<methodsynopsis>
12
-
<type>resource</type><methodname>oci_new_connect</methodname>
12
+
<type class="union"><type>resource</type><type>false</type></type><methodname>oci_new_connect</methodname>
13
13
<methodparam><type>string</type><parameter>username</parameter></methodparam>
14
14
<methodparam><type>string</type><parameter>password</parameter></methodparam>
15
-
<methodparam choice="opt"><type>string</type><parameter>connection_string</parameter></methodparam>
16
-
<methodparam choice="opt"><type>string</type><parameter>character_set</parameter></methodparam>
17
-
<methodparam choice="opt"><type>int</type><parameter>session_mode</parameter></methodparam>
15
+
<methodparam choice="opt"><type class="union"><type>string</type><type>null</type></type><parameter>connection_string</parameter><initializer>&null;</initializer></methodparam>
16
+
<methodparam choice="opt"><type>string</type><parameter>encoding</parameter><initializer>""</initializer></methodparam>
17
+
<methodparam choice="opt"><type>int</type><parameter>session_mode</parameter><initializer><constant>OCI_DEFAULT</constant></initializer></methodparam>
18
18
</methodsynopsis>
19
19
<para>
20
20
Establishes a new connection to an Oracle server and logs on.
...
...
@@ -55,7 +55,7 @@
55
55
</listitem>
56
56
</varlistentry>
57
57
<varlistentry>
58
-
<term><parameter>character_set</parameter></term>
58
+
<term><parameter>encoding</parameter></term>
59
59
<listitem>
60
60
&oci.charset;
61
61
</listitem>
...
...
@@ -77,6 +77,28 @@
77
77
</para>
78
78
</refsect1>
79
79

80
+
<refsect1 role="changelog">
81
+
&reftitle.changelog;
82
+
<informaltable>
83
+
<tgroup cols="2">
84
+
<thead>
85
+
<row>
86
+
<entry>&Version;</entry>
87
+
<entry>&Description;</entry>
88
+
</row>
89
+
</thead>
90
+
<tbody>
91
+
<row>
92
+
<entry>8.0.0, PECL OCI8 3.0.0</entry>
93
+
<entry>
94
+
<parameter>connection_string</parameter> is now nullable.
95
+
</entry>
96
+
</row>
97
+
</tbody>
98
+
</tgroup>
99
+
</informaltable>
100
+
</refsect1>
101
+

80
102
<refsect1 role="examples">
81
103
&reftitle.examples;
82
104
<para>
...
...
@@ -86,107 +108,53 @@
86
108
<programlisting role="php">
87
109
<![CDATA[
88
110
<?php
89
-
echo "<html><pre>";
90
-
$db = "";
91
111

92
-
$c1 = oci_connect("scott", "tiger", $db);
93
-
$c2 = oci_new_connect("scott", "tiger", $db);
112
+
// create table mytab (mycol number);
94
113

95
-
function create_table($conn)
114
+
function query($name, $c)
96
115
{
97
-
$stmt = oci_parse($conn, "create table scott.hallo (test
98
-
varchar2(64))");
99
-
oci_execute($stmt);
100
-
echo $conn . " created table\n\n";
116
+
echo "Querying $name\n";
117
+
$s = oci_parse($c, "select * from mytab");
118
+
oci_execute($s, OCI_NO_AUTO_COMMIT);
119
+
$row = oci_fetch_array($s, OCI_ASSOC);
120
+
if (!$row) {
121
+
echo "No rows\n";
122
+
} else {
123
+
do {
124
+
foreach ($row as $item)
125
+
echo $item . " ";
126
+
echo "\n";
127
+
} while (($row = oci_fetch_array($s, OCI_ASSOC)) != false);
128
+
}
101
129
}
102
130

103
-
function drop_table($conn)
104
-
{
105
-
$stmt = oci_parse($conn, "drop table scott.hallo");
106
-
oci_execute($stmt);
107
-
echo $conn . " dropped table\n\n";
108
-
}
131
+
$c1 = oci_connect("hr", "welcome", "localhost/orcl");
132
+
$c2 = oci_new_connect("hr", "welcome", "localhost/orcl");
109
133

110
-
function insert_data($conn)
111
-
{
112
-
$stmt = oci_parse($conn, "insert into scott.hallo
113
-
values('$conn' || ' ' || to_char(sysdate,'DD-MON-YY HH24:MI:SS'))");
114
-
oci_execute($stmt, OCI_DEFAULT);
115
-
echo $conn . " inserted hallo\n\n";
116
-
}
134
+
$s = oci_parse($c1, "insert into mytab values(1234)");
135
+
oci_execute($s, OCI_NO_AUTO_COMMIT);
117
136

118
-
function delete_data($conn)
119
-
{
120
-
$stmt = oci_parse($conn, "delete from scott.hallo");
121
-
oci_execute($stmt, OCI_DEFAULT);
122
-
echo $conn . " deleted hallo\n\n";
123
-
}
137
+
query("basic connection", $c1);
138
+
query("new connection", $c2);
139
+
oci_commit($c1);
140
+
query("new connection after commit", $c2);
124
141

125
-
function commit($conn)
126
-
{
127
-
oci_commit($conn);
128
-
echo $conn . " committed\n\n";
129
-
}
142
+
// Output is:
143
+
// Querying basic connection
144
+
// 1234
145
+
// Querying new connection
146
+
// No rows
147
+
// Querying new connection after commit
148
+
// 1234
130
149

131
-
function rollback($conn)
132
-
{
133
-
oci_rollback($conn);
134
-
echo $conn . " rollback\n\n";
135
-
}
136
-

137
-
function select_data($conn)
138
-
{
139
-
$stmt = oci_parse($conn, "select * from scott.hallo");
140
-
oci_execute($stmt, OCI_DEFAULT);
141
-
echo $conn . "----selecting\n\n";
142
-
while (oci_fetch($stmt)) {
143
-
echo $conn . " <" . oci_result($stmt, "TEST") . ">\n\n";
144
-
}
145
-
echo $conn . "----done\n\n";
146
-
}
147
-

148
-
create_table($c1);
149
-
insert_data($c1);
150
-

151
-
select_data($c1);
152
-
select_data($c2);
153
-

154
-
rollback($c1);
155
-

156
-
select_data($c1);
157
-
select_data($c2);
158
-

159
-
insert_data($c2);
160
-
commit($c2);
161
-

162
-
select_data($c1);
163
-

164
-
delete_data($c1);
165
-
select_data($c1);
166
-
select_data($c2);
167
-
commit($c1);
168
-

169
-
select_data($c1);
170
-
select_data($c2);
171
-

172
-
drop_table($c1);
173
-
echo "</pre></html>";
174
150
?>
175
151
]]>
176
152
</programlisting>
177
153
</example>
178
154
</para>
179
-
</refsect1>
180
-

181
-
<refsect1 role="notes">
182
-
&reftitle.notes;
183
-
<note>
184
-
<para>
185
-
In PHP versions before 5.0.0 you must
186
-
use <function>ocinlogon</function> instead.
187
-
&oci.name.compat.note;
188
-
</para>
189
-
</note>
155
+
<para>
156
+
See <function>oci_connect</function> for further examples of parameter usage.
157
+
</para>
190
158
</refsect1>
191
159

192
160
<refsect1 role="seealso">
...
...
@@ -200,7 +168,6 @@ echo "</pre></html>";
200
168
</refsect1>
201
169

202
170
</refentry>
203
-

204
171
<!-- Keep this comment at the end of the file
205
172
Local variables:
206
173
mode: sgml
207
174