-
Notifications
You must be signed in to change notification settings - Fork 146
/
oci-new-descriptor.xml
201 lines (191 loc) · 6.03 KB
/
oci-new-descriptor.xml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
<?xml version="1.0" encoding="utf-8"?>
<!-- $Revision$ -->
<!-- EN-Revision: 5e41012cfdf8f2eff5fa56de446c7656afac536c Maintainer: yannick Status: ready -->
<!-- Reviewed: yes Maintainer: mikaelkael -->
<refentry xml:id="function.oci-new-descriptor" xmlns="http://docbook.org/ns/docbook">
<refnamediv>
<refname>oci_new_descriptor</refname>
<refpurpose>Initialise un nouveau pointeur vide de LOB/FILE Oracle</refpurpose>
</refnamediv>
<refsect1 role="description">
&reftitle.description;
<methodsynopsis>
<type class="union"><type>OCILob</type><type>null</type></type><methodname>oci_new_descriptor</methodname>
<methodparam><type>resource</type><parameter>connection</parameter></methodparam>
<methodparam choice="opt"><type>int</type><parameter>type</parameter><initializer><constant>OCI_DTYPE_LOB</constant></initializer></methodparam>
</methodsynopsis>
<para>
Initialise un nouveau pointeur vide de LOB/FILE Oracle.
</para>
</refsect1>
<refsect1 role="parameters">
&reftitle.parameters;
<para>
<variablelist>
<varlistentry>
<term><parameter>connection</parameter></term>
<listitem>
<para>
Un identifiant de connexion Oracle, retourné par la fonction
<function>oci_connect</function> ou la fonction
<function>oci_pconnect</function>.
</para>
</listitem>
</varlistentry>
<varlistentry>
<term><parameter>type</parameter></term>
<listitem>
<para>
Les valeurs acceptées pour <parameter>type</parameter> sont :
<constant>OCI_D_FILE</constant>,
<constant>OCI_D_LOB</constant> et <constant>OCI_D_ROWID</constant>.
</para>
</listitem>
</varlistentry>
</variablelist>
</para>
</refsect1>
<refsect1 role="returnvalues">
&reftitle.returnvalues;
<para>
Retourne une nouvelle ressource LOB ou FILE en cas de succès,
ou &null; en cas d'échec.
</para>
</refsect1>
<refsect1 role="examples">
&reftitle.examples;
<para>
<example>
<title>Exemple avec <function>oci_new_descriptor</function></title>
<programlisting role="php">
<![CDATA[
<?php
/* Ce script est fait pour être appelé dans un formulaire HTML
* Il attend les variables $user, $password, $table, $where, et $commitsize
* Le script efface alors les lignes sélectionnées avec ROWID et valide
* l'effacement après chaque groupe de $commitsize lignes.
* (Utilisez avec prudence, car il n'y a pas d'annulation possible).
*/
$conn = oci_connect($user, $password);
$stmt = oci_parse($conn, "select rowid from $table $where");
$rowid = oci_new_descriptor($conn, OCI_D_ROWID);
oci_define_by_name($stmt, "ROWID", $rowid);
oci_execute($stmt);
while (oci_fetch($stmt)) {
$nrows = oci_num_rows($stmt);
$delete = oci_parse($conn, "delete from $table where ROWID = :rid");
oci_bind_by_name($delete, ":rid", $rowid, -1, OCI_B_ROWID);
oci_execute($delete);
echo "$nrows\n";
if (($nrows % $commitsize) == 0) {
oci_commit($conn);
}
}
$nrows = oci_num_rows($stmt);
echo "$nrows deleted...\n";
oci_free_statement($stmt);
oci_close($conn);
?>
]]>
</programlisting>
<programlisting role="php">
<![CDATA[
<?php
/* Ce script illustre le chargement de colonnes de type LOB
* Le formulaire utilisé dans cet exemple ressemble à ceci :
* <form action="upload.php" method="post" enctype="multipart/form-data">
* <input type="file" name="lob_upload" />
* ...
*/
if (!isset($lob_upload) || $lob_upload == 'none'){
?>
<form action="upload.php" method="post" enctype="multipart/form-data">
Upload file: <input type="file" name="lob_upload" /><br />
<input type="submit" value="Upload" /> - <input type="reset" value="Reset" />
</form>
<?php
} else {
// $lob_upload contient le fichier temporaire
// Reportez-vous à la section sur le téléchargement de fichiers
// pour sécuriser vos téléchargements
$conn = oci_connect($user, $password);
$lob = oci_new_descriptor($conn, OCI_D_LOB);
$stmt = oci_parse($conn, "insert into $table (id, the_blob)
values(my_seq.NEXTVAL, EMPTY_BLOB()) returning the_blob into :the_blob");
oci_bind_by_name($stmt, ':the_blob', $lob, -1, OCI_B_BLOB);
oci_execute($stmt, OCI_DEFAULT);
if ($lob->savefile($lob_upload)){
oci_commit($conn);
echo "BLOB chargé !\n";
}else{
echo "Impossible de charger le BLOB\n";
}
$lob->free();
oci_free_statement($stmt);
oci_close($conn);
}
?>
]]>
</programlisting>
</example>
<example>
<title>Exemple avec <function>oci_new_descriptor</function></title>
<programlisting role="php">
<![CDATA[
<?php
/* Appel d'une procédure PL/SQL stockée qui prend un clob
* en entrée.
* Exemple de signateure de procédure stockée PL/SQL :
*
* PROCEDURE save_data
* Argument Name Type In/Out Default?
* ------------------------------ ----------------------- ------ --------
* KEY NUMBER(38) IN
* DATA CLOB IN
*
*/
$conn = oci_connect($user, $password);
$stmt = oci_parse($conn, "begin save_data(:key, :data); end;");
$clob = oci_new_descriptor($conn, OCI_D_LOB);
oci_bind_by_name($stmt, ':key', $key);
oci_bind_by_name($stmt, ':data', $clob, -1, OCI_B_CLOB);
$clob->write($data);
oci_execute($stmt, OCI_DEFAULT);
oci_commit($conn);
$clob->free();
oci_free_statement($stmt);
?>
]]>
</programlisting>
</example>
</para>
</refsect1>
<refsect1 role="seealso">
&reftitle.seealso;
<para>
<simplelist>
<member><function>oci_bind_by_name</function></member>
</simplelist>
</para>
</refsect1>
</refentry>
<!-- Keep this comment at the end of the file
Local variables:
mode: sgml
sgml-omittag:t
sgml-shorttag:t
sgml-minimize-attributes:nil
sgml-always-quote-attributes:t
sgml-indent-step:1
sgml-indent-data:t
indent-tabs-mode:nil
sgml-parent-document:nil
sgml-default-dtd-file:"~/.phpdoc/manual.ced"
sgml-exposed-tags:nil
sgml-local-catalogs:nil
sgml-local-ecat-files:nil
End:
vim600: syn=xml fen fdm=syntax fdl=2 si
vim: et tw=78 syn=sgml
vi: ts=1 sw=1
-->