source: www/manuals/PHP_manual/function.ocibindbyname.html@ 1

Last change on this file since 1 was 1, checked in by george, 17 years ago

Prvotní import všeho

File size: 5.7 KB
Line 
1<HTML
2><HEAD
3><TITLE
4>OCIBindByName</TITLE
5><META
6NAME="GENERATOR"
7CONTENT="Modular DocBook HTML Stylesheet Version 1.7"><LINK
8REL="HOME"
9TITLE="Manuál PHP"
10HREF="index.html"><LINK
11REL="UP"
12TITLE="Oracle 8 functions"
13HREF="ref.oci8.html"><LINK
14REL="PREVIOUS"
15TITLE="Oracle 8 functions"
16HREF="ref.oci8.html"><LINK
17REL="NEXT"
18TITLE="OCICancel"
19HREF="function.ocicancel.html"><META
20HTTP-EQUIV="Content-type"
21CONTENT="text/html; charset=ISO-8859-2"></HEAD
22><BODY
23CLASS="refentry"
24BGCOLOR="#FFFFFF"
25TEXT="#000000"
26LINK="#0000FF"
27VLINK="#840084"
28ALINK="#0000FF"
29><DIV
30CLASS="NAVHEADER"
31><TABLE
32SUMMARY="Header navigation table"
33WIDTH="100%"
34BORDER="0"
35CELLPADDING="0"
36CELLSPACING="0"
37><TR
38><TH
39COLSPAN="3"
40ALIGN="center"
41>Manuál PHP</TH
42></TR
43><TR
44><TD
45WIDTH="10%"
46ALIGN="left"
47VALIGN="bottom"
48><A
49HREF="ref.oci8.html"
50ACCESSKEY="P"
51>Pøedcházející</A
52></TD
53><TD
54WIDTH="80%"
55ALIGN="center"
56VALIGN="bottom"
57></TD
58><TD
59WIDTH="10%"
60ALIGN="right"
61VALIGN="bottom"
62><A
63HREF="function.ocicancel.html"
64ACCESSKEY="N"
65>Dal¹í</A
66></TD
67></TR
68></TABLE
69><HR
70ALIGN="LEFT"
71WIDTH="100%"></DIV
72><H1
73><A
74NAME="function.ocibindbyname"
75></A
76>OCIBindByName</H1
77><DIV
78CLASS="refnamediv"
79><A
80NAME="AEN61915"
81></A
82><P
83> (PHP 3&#62;= 3.0.4, PHP 4 )</P
84>OCIBindByName&nbsp;--&nbsp;
85 Bind a PHP variable to an Oracle Placeholder
86 </DIV
87><DIV
88CLASS="refsect1"
89><A
90NAME="AEN61918"
91></A
92><H2
93>Description</H2
94>bool <B
95CLASS="methodname"
96>OCIBindByName</B
97> ( int stmt, string ph_name, mixed &#38; variable, int length [, int type])<BR
98></BR
99><P
100>&#13; <B
101CLASS="function"
102>OCIBindByName()</B
103> binds the PHP variable
104 <TT
105CLASS="parameter"
106><I
107>variable</I
108></TT
109> to the Oracle placeholder
110 <TT
111CLASS="parameter"
112><I
113>ph_name</I
114></TT
115>. Whether it will be used for
116 input or output will be determined run-time, and the necessary
117 storage space will be allocated. The
118 <TT
119CLASS="parameter"
120><I
121>length</I
122></TT
123> parameter sets the maximum length
124 for the bind. If you set <TT
125CLASS="parameter"
126><I
127>length</I
128></TT
129> to -1
130 <B
131CLASS="function"
132>OCIBindByName()</B
133> will use the current length of
134 <TT
135CLASS="parameter"
136><I
137>variable</I
138></TT
139> to set the maximum length.
140 </P
141><P
142>&#13; If you need to bind an abstract Datatype (LOB/ROWID/BFILE) you
143 need to allocate it first using
144 <A
145HREF="function.ocinewdescriptor.html"
146><B
147CLASS="function"
148>OCINewDescriptor()</B
149></A
150> function. The
151 <TT
152CLASS="parameter"
153><I
154>length</I
155></TT
156> is not used for abstract Datatypes
157 and should be set to -1. The <TT
158CLASS="parameter"
159><I
160>type</I
161></TT
162> variable
163 tells oracle, what kind of descriptor we want to use. Possible
164 values are: OCI_B_FILE (Binary-File), OCI_B_CFILE
165 (Character-File), OCI_B_CLOB (Character-LOB), OCI_B_BLOB
166 (Binary-LOB) and OCI_B_ROWID (ROWID).
167 </P
168><TABLE
169WIDTH="100%"
170BORDER="0"
171CELLPADDING="0"
172CELLSPACING="0"
173CLASS="EXAMPLE"
174><TR
175><TD
176><DIV
177CLASS="example"
178><A
179NAME="AEN61950"
180></A
181><P
182><B
183>Pøíklad 1. OCIDefineByName</B
184></P
185><TABLE
186BORDER="0"
187BGCOLOR="#E0E0E0"
188CELLPADDING="5"
189><TR
190><TD
191><PRE
192CLASS="programlisting"
193>&#60;?php
194/* OCIBindByPos example thies@thieso.net (980221)
195 inserts 3 records into emp, and uses the ROWID for updating the
196 records just after the insert.
197*/
198
199$conn = OCILogon("scott","tiger");
200
201$stmt = OCIParse($conn,"insert into emp (empno, ename) ".
202 "values (:empno,:ename) ".
203 "returning ROWID into :rid");
204
205$data = array(1111 =&#62; "Larry", 2222 =&#62; "Bill", 3333 =&#62; "Jim");
206
207$rowid = OCINewDescriptor($conn,OCI_D_ROWID);
208
209OCIBindByName($stmt,":empno",&#38;$empno,32);
210OCIBindByName($stmt,":ename",&#38;$ename,32);
211OCIBindByName($stmt,":rid",&#38;$rowid,-1,OCI_B_ROWID);
212
213$update = OCIParse($conn,"update emp set sal = :sal where ROWID = :rid");
214OCIBindByName($update,":rid",&#38;$rowid,-1,OCI_B_ROWID);
215OCIBindByName($update,":sal",&#38;$sal,32);
216
217$sal = 10000;
218
219while (list($empno,$ename) = each($data)) {
220 OCIExecute($stmt);
221 OCIExecute($update);
222}
223
224$rowid-&#62;free();
225
226OCIFreeStatement($update);
227OCIFreeStatement($stmt);
228
229$stmt = OCIParse($conn,"select * from emp where empno in (1111,2222,3333)");
230OCIExecute($stmt);
231while (OCIFetchInto($stmt,&#38;$arr,OCI_ASSOC)) {
232 var_dump($arr);
233}
234OCIFreeStatement($stmt);
235
236/* delete our "junk" from the emp table.... */
237$stmt = OCIParse($conn,"delete from emp where empno in (1111,2222,3333)");
238OCIExecute($stmt);
239OCIFreeStatement($stmt);
240
241OCILogoff($conn);
242?&#62;</PRE
243></TD
244></TR
245></TABLE
246></DIV
247></TD
248></TR
249></TABLE
250><DIV
251CLASS="warning"
252><P
253></P
254><TABLE
255CLASS="warning"
256BORDER="1"
257WIDTH="100%"
258><TR
259><TD
260ALIGN="CENTER"
261><B
262>Varování</B
263></TD
264></TR
265><TR
266><TD
267ALIGN="LEFT"
268><P
269>&#13; It is a bad idea to use magic quotes and
270 <B
271CLASS="function"
272>OciBindByName()</B
273> simultaneously as no quoting
274 is needed on quoted variables and any quotes magically applied
275 will be written into your database as
276 <B
277CLASS="function"
278>OciBindByName()</B
279> is not able to distinguish
280 magically added quotings from those added by intention.
281 </P
282></TD
283></TR
284></TABLE
285></DIV
286></DIV
287><DIV
288CLASS="NAVFOOTER"
289><HR
290ALIGN="LEFT"
291WIDTH="100%"><TABLE
292SUMMARY="Footer navigation table"
293WIDTH="100%"
294BORDER="0"
295CELLPADDING="0"
296CELLSPACING="0"
297><TR
298><TD
299WIDTH="33%"
300ALIGN="left"
301VALIGN="top"
302><A
303HREF="ref.oci8.html"
304ACCESSKEY="P"
305>Pøedcházející</A
306></TD
307><TD
308WIDTH="34%"
309ALIGN="center"
310VALIGN="top"
311><A
312HREF="index.html"
313ACCESSKEY="H"
314>Domù</A
315></TD
316><TD
317WIDTH="33%"
318ALIGN="right"
319VALIGN="top"
320><A
321HREF="function.ocicancel.html"
322ACCESSKEY="N"
323>Dal¹í</A
324></TD
325></TR
326><TR
327><TD
328WIDTH="33%"
329ALIGN="left"
330VALIGN="top"
331>Oracle 8 functions</TD
332><TD
333WIDTH="34%"
334ALIGN="center"
335VALIGN="top"
336><A
337HREF="ref.oci8.html"
338ACCESSKEY="U"
339>Nahoru</A
340></TD
341><TD
342WIDTH="33%"
343ALIGN="right"
344VALIGN="top"
345>OCICancel</TD
346></TR
347></TABLE
348></DIV
349></BODY
350></HTML
351>
Note: See TracBrowser for help on using the repository browser.