<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> <HTML ><HEAD ><TITLE >ocibindbyname</TITLE ><META NAME="GENERATOR" CONTENT="Modular DocBook HTML Stylesheet Version 1.79"><LINK REL="HOME" TITLE="Manual do PHP" HREF="index.html"><LINK REL="UP" TITLE="Funções do Oracle 8" HREF="ref.oci8.html"><LINK REL="PREVIOUS" TITLE="oci_statement_type" HREF="function.oci-statement-type.html"><LINK REL="NEXT" TITLE="ocicancel" HREF="function.ocicancel.html"><META HTTP-EQUIV="Content-type" CONTENT="text/html; charset=UTF-8"></HEAD ><BODY CLASS="refentry" BGCOLOR="#FFFFFF" TEXT="#000000" LINK="#0000FF" VLINK="#840084" ALINK="#0000FF" ><DIV CLASS="NAVHEADER" ><TABLE SUMMARY="Header navigation table" WIDTH="100%" BORDER="0" CELLPADDING="0" CELLSPACING="0" ><TR ><TH COLSPAN="3" ALIGN="center" >Manual do PHP</TH ></TR ><TR ><TD WIDTH="10%" ALIGN="left" VALIGN="bottom" ><A HREF="function.oci-statement-type.html" ACCESSKEY="P" >Anterior</A ></TD ><TD WIDTH="80%" ALIGN="center" VALIGN="bottom" ></TD ><TD WIDTH="10%" ALIGN="right" VALIGN="bottom" ><A HREF="function.ocicancel.html" ACCESSKEY="N" >Próxima</A ></TD ></TR ></TABLE ><HR ALIGN="LEFT" WIDTH="100%"></DIV ><H1 ><A NAME="function.ocibindbyname" ></A >ocibindbyname</H1 ><DIV CLASS="refnamediv" ><A NAME="AEN154492" ></A ><P > (PHP 3 >= 3.0.4, PHP 4, PHP 5)</P >ocibindbyname -- Passa variáveis PHP para um ambiente de armazenamento do Oracle </DIV ><DIV CLASS="refsect1" ><A NAME="AEN154495" ></A ><H2 >Descrição</H2 >bool <B CLASS="methodname" >ocibindbyname</B > ( resource stmt, string ph_name, mixed &variable [, int maxlength [, int type]] )<BR ></BR ><P > <B CLASS="function" >ocibindbyname()</B > passa uma variável PHP <CODE CLASS="parameter" >variable</CODE > para um ambiente de armazenamento no Oracle <CODE CLASS="parameter" >ph_name</CODE >. Se isso for usado para entrada ou saída de dados irá ser determinado "run-time", e o espaço necessário para armazenagem será alocado. O parâmetro <CODE CLASS="parameter" >length</CODE > seta o comprimento máximo para passar. Se você setar <CODE CLASS="parameter" >length</CODE > como -1 <B CLASS="function" >ocibindbyname()</B > irá usar o comprimento atual da <CODE CLASS="parameter" >variable</CODE > para setar o comprimento máximo. </P ><P > Se você precisar passar um tipo de dados abstrato (LOB/ROWID/BFILE) você precisa alocar isso primeiro usando a função <A HREF="function.ocinewdescriptor.html" ><B CLASS="function" >ocinewdescriptor()</B ></A >. O <CODE CLASS="parameter" >length</CODE > não é usado para tipo de dados abstratos e deve ser setado como -1. A variável <CODE CLASS="parameter" >type</CODE > diz ao Oracle, qual classificação nós queremos usar. Valores possíveis são: OCI_B_FILE (Binary-File), OCI_B_CFILE (Character-File), OCI_B_CLOB (Character-LOB), OCI_B_BLOB (Binary-LOB) e OCI_B_ROWID (ROWID). </P ><P > <TABLE WIDTH="100%" BORDER="0" CELLPADDING="0" CELLSPACING="0" CLASS="EXAMPLE" ><TR ><TD ><DIV CLASS="example" ><A NAME="AEN154528" ></A ><P ><B >Exemplo 1. <B CLASS="function" >ocibindbyname()</B > example</B ></P ><TABLE BORDER="0" BGCOLOR="#E0E0E0" CELLPADDING="5" ><TR ><TD ><code><font color="#000000"> <font color="#0000BB"><?php<br /></font><font color="#FF8000">/* OCIBindByPos example thies at thieso dot net (980221)<br /> inserts 3 records into emp, and uses the ROWID for updating the <br /> records just after the insert.<br />*/<br /><br /></font><font color="#0000BB">$conn </font><font color="#007700">= </font><font color="#0000BB">OCILogon</font><font color="#007700">(</font><font color="#DD0000">"scott"</font><font color="#007700">,</font><font color="#DD0000">"tiger"</font><font color="#007700">);<br /><br /></font><font color="#0000BB">$stmt </font><font color="#007700">= </font><font color="#0000BB">OCIParse</font><font color="#007700">(</font><font color="#0000BB">$conn</font><font color="#007700">,</font><font color="#DD0000">"insert into emp (empno, ename) "</font><font color="#007700">.<br /> </font><font color="#DD0000">"values (:empno,:ename) "</font><font color="#007700">.<br /> </font><font color="#DD0000">"returning ROWID into :rid"</font><font color="#007700">);<br /><br /></font><font color="#0000BB">$data </font><font color="#007700">= array(</font><font color="#0000BB">1111 </font><font color="#007700">=> </font><font color="#DD0000">"Larry"</font><font color="#007700">, </font><font color="#0000BB">2222 </font><font color="#007700">=> </font><font color="#DD0000">"Bill"</font><font color="#007700">, </font><font color="#0000BB">3333 </font><font color="#007700">=> </font><font color="#DD0000">"Jim"</font><font color="#007700">);<br /><br /></font><font color="#0000BB">$rowid </font><font color="#007700">= </font><font color="#0000BB">OCINewDescriptor</font><font color="#007700">(</font><font color="#0000BB">$conn</font><font color="#007700">,</font><font color="#0000BB">OCI_D_ROWID</font><font color="#007700">);<br /><br /></font><font color="#0000BB">OCIBindByName</font><font color="#007700">(</font><font color="#0000BB">$stmt</font><font color="#007700">,</font><font color="#DD0000">":empno"</font><font color="#007700">,&</font><font color="#0000BB">$empno</font><font color="#007700">,</font><font color="#0000BB">32</font><font color="#007700">);<br /></font><font color="#0000BB">OCIBindByName</font><font color="#007700">(</font><font color="#0000BB">$stmt</font><font color="#007700">,</font><font color="#DD0000">":ename"</font><font color="#007700">,&</font><font color="#0000BB">$ename</font><font color="#007700">,</font><font color="#0000BB">32</font><font color="#007700">);<br /></font><font color="#0000BB">OCIBindByName</font><font color="#007700">(</font><font color="#0000BB">$stmt</font><font color="#007700">,</font><font color="#DD0000">":rid"</font><font color="#007700">,&</font><font color="#0000BB">$rowid</font><font color="#007700">,-</font><font color="#0000BB">1</font><font color="#007700">,</font><font color="#0000BB">OCI_B_ROWID</font><font color="#007700">);<br /><br /></font><font color="#0000BB">$update </font><font color="#007700">= </font><font color="#0000BB">OCIParse</font><font color="#007700">(</font><font color="#0000BB">$conn</font><font color="#007700">,</font><font color="#DD0000">"update emp set sal = :sal where ROWID = :rid"</font><font color="#007700">);<br /></font><font color="#0000BB">OCIBindByName</font><font color="#007700">(</font><font color="#0000BB">$update</font><font color="#007700">,</font><font color="#DD0000">":rid"</font><font color="#007700">,&</font><font color="#0000BB">$rowid</font><font color="#007700">,-</font><font color="#0000BB">1</font><font color="#007700">,</font><font color="#0000BB">OCI_B_ROWID</font><font color="#007700">);<br /></font><font color="#0000BB">OCIBindByName</font><font color="#007700">(</font><font color="#0000BB">$update</font><font color="#007700">,</font><font color="#DD0000">":sal"</font><font color="#007700">,&</font><font color="#0000BB">$sal</font><font color="#007700">,</font><font color="#0000BB">32</font><font color="#007700">);<br /><br /></font><font color="#0000BB">$sal </font><font color="#007700">= </font><font color="#0000BB">10000</font><font color="#007700">;<br /><br />while (list(</font><font color="#0000BB">$empno</font><font color="#007700">,</font><font color="#0000BB">$ename</font><font color="#007700">) = </font><font color="#0000BB">each</font><font color="#007700">(</font><font color="#0000BB">$data</font><font color="#007700">)) {<br /> </font><font color="#0000BB">OCIExecute</font><font color="#007700">(</font><font color="#0000BB">$stmt</font><font color="#007700">);<br /> </font><font color="#0000BB">OCIExecute</font><font color="#007700">(</font><font color="#0000BB">$update</font><font color="#007700">);<br />} <br /><br /></font><font color="#0000BB">$rowid</font><font color="#007700">-></font><font color="#0000BB">free</font><font color="#007700">();<br /><br /></font><font color="#0000BB">OCIFreeStatement</font><font color="#007700">(</font><font color="#0000BB">$update</font><font color="#007700">);<br /></font><font color="#0000BB">OCIFreeStatement</font><font color="#007700">(</font><font color="#0000BB">$stmt</font><font color="#007700">);<br /><br /></font><font color="#0000BB">$stmt </font><font color="#007700">= </font><font color="#0000BB">OCIParse</font><font color="#007700">(</font><font color="#0000BB">$conn</font><font color="#007700">,</font><font color="#DD0000">"select * from emp where empno in (1111,2222,3333)"</font><font color="#007700">);<br /></font><font color="#0000BB">OCIExecute</font><font color="#007700">(</font><font color="#0000BB">$stmt</font><font color="#007700">);<br />while (</font><font color="#0000BB">OCIFetchInto</font><font color="#007700">(</font><font color="#0000BB">$stmt</font><font color="#007700">,&</font><font color="#0000BB">$arr</font><font color="#007700">,</font><font color="#0000BB">OCI_ASSOC</font><font color="#007700">)) {<br /> </font><font color="#0000BB">var_dump</font><font color="#007700">(</font><font color="#0000BB">$arr</font><font color="#007700">);<br />}<br /></font><font color="#0000BB">OCIFreeStatement</font><font color="#007700">(</font><font color="#0000BB">$stmt</font><font color="#007700">);<br /><br /></font><font color="#FF8000">/* delete our "junk" from the emp table.... */<br /></font><font color="#0000BB">$stmt </font><font color="#007700">= </font><font color="#0000BB">OCIParse</font><font color="#007700">(</font><font color="#0000BB">$conn</font><font color="#007700">,</font><font color="#DD0000">"delete from emp where empno in (1111,2222,3333)"</font><font color="#007700">);<br /></font><font color="#0000BB">OCIExecute</font><font color="#007700">(</font><font color="#0000BB">$stmt</font><font color="#007700">);<br /></font><font color="#0000BB">OCIFreeStatement</font><font color="#007700">(</font><font color="#0000BB">$stmt</font><font color="#007700">);<br /><br /></font><font color="#0000BB">OCILogoff</font><font color="#007700">(</font><font color="#0000BB">$conn</font><font color="#007700">);<br /></font><font color="#0000BB">?></font> </font> </code></TD ></TR ></TABLE ></DIV ></TD ></TR ></TABLE > </P ><DIV CLASS="warning" ><P ></P ><TABLE CLASS="warning" BORDER="1" WIDTH="100%" ><TR ><TD ALIGN="CENTER" ><B >Atenção</B ></TD ></TR ><TR ><TD ALIGN="LEFT" ><P > É uma má idéia usar magic quotes e <B CLASS="function" >ocibindbyname()</B > simultâneamente, nenhuma aspas são necessárias em variáveis que já possuem e alguma aspas magicamente aplicadas irão ser escritas dentro do seu database como <B CLASS="function" >ocibindbyname()</B > não está habilitada para distinguir aspas magicamente adicionadas para estas adicionadas intencionalmente. </P ></TD ></TR ></TABLE ></DIV ></DIV ><DIV CLASS="NAVFOOTER" ><HR ALIGN="LEFT" WIDTH="100%"><TABLE SUMMARY="Footer navigation table" WIDTH="100%" BORDER="0" CELLPADDING="0" CELLSPACING="0" ><TR ><TD WIDTH="33%" ALIGN="left" VALIGN="top" ><A HREF="function.oci-statement-type.html" ACCESSKEY="P" >Anterior</A ></TD ><TD WIDTH="34%" ALIGN="center" VALIGN="top" ><A HREF="index.html" ACCESSKEY="H" >Principal</A ></TD ><TD WIDTH="33%" ALIGN="right" VALIGN="top" ><A HREF="function.ocicancel.html" ACCESSKEY="N" >Próxima</A ></TD ></TR ><TR ><TD WIDTH="33%" ALIGN="left" VALIGN="top" >oci_statement_type</TD ><TD WIDTH="34%" ALIGN="center" VALIGN="top" ><A HREF="ref.oci8.html" ACCESSKEY="U" >Acima</A ></TD ><TD WIDTH="33%" ALIGN="right" VALIGN="top" >ocicancel</TD ></TR ></TABLE ></DIV ></BODY ></HTML >