mirror of
https://github.com/sigmasternchen/php-doc-en
synced 2025-03-27 06:18:56 +00:00

git-svn-id: https://svn.php.net/repository/phpdoc/en/trunk@165127 c90b9560-bf6c-de11-be94-00142212c4b1
149 lines
4.8 KiB
XML
149 lines
4.8 KiB
XML
<?xml version="1.0" encoding="iso-8859-1"?>
|
|
<!-- $Revision: 1.15 $ -->
|
|
<!--
|
|
|
|
DO NOT TRANSLATE THIS FILE.
|
|
THE FUNCTION IT DESCRIBES WAS RENAMED AND THIS NAME IS DEPRECATED.
|
|
PLEASE, TRANSLATE THE APPROPRIATE NEW FILE.
|
|
|
|
-->
|
|
<!-- splitted from ./en/functions/oci8.xml, last change in rev 1.2 -->
|
|
<refentry id="function.ocibindbyname">
|
|
<refnamediv>
|
|
<refname>ocibindbyname</refname>
|
|
<refpurpose>
|
|
Bind a PHP variable to an Oracle Placeholder
|
|
</refpurpose>
|
|
</refnamediv>
|
|
<refsect1>
|
|
<title>Description</title>
|
|
<methodsynopsis>
|
|
<type>bool</type><methodname>ocibindbyname</methodname>
|
|
<methodparam><type>resource</type><parameter>stmt</parameter></methodparam>
|
|
<methodparam><type>string</type><parameter>ph_name</parameter></methodparam>
|
|
<methodparam><type>mixed</type><parameter>&variable</parameter></methodparam>
|
|
<methodparam choice="opt"><type>int</type><parameter>maxlength</parameter></methodparam>
|
|
<methodparam choice="opt"><type>int</type><parameter>type</parameter></methodparam>
|
|
</methodsynopsis>
|
|
<para>
|
|
<function>ocibindbyname</function> binds the PHP variable
|
|
<parameter>variable</parameter> to the Oracle placeholder
|
|
<parameter>ph_name</parameter>. Whether it will be used for
|
|
input or output will be determined run-time, and the necessary
|
|
storage space will be allocated. The
|
|
<parameter>length</parameter> parameter sets the maximum length
|
|
for the bind. If you set <parameter>length</parameter> to -1
|
|
<function>ocibindbyname</function> will use the current length of
|
|
<parameter>variable</parameter> to set the maximum length.
|
|
</para>
|
|
<para>
|
|
If you need to bind an abstract Datatype (LOB/ROWID/BFILE) you
|
|
need to allocate it first using
|
|
<function>ocinewdescriptor</function> function. The
|
|
<parameter>length</parameter> is not used for abstract Datatypes
|
|
and should be set to -1. The <parameter>type</parameter> variable
|
|
tells oracle, what kind of descriptor we want to use. Possible
|
|
values are: OCI_B_FILE (Binary-File), OCI_B_CFILE
|
|
(Character-File), OCI_B_CLOB (Character-LOB), OCI_B_BLOB
|
|
(Binary-LOB) and OCI_B_ROWID (ROWID).
|
|
</para>
|
|
<para>
|
|
<example>
|
|
<title><function>ocibindbyname</function> example</title>
|
|
<programlisting role="php">
|
|
<![CDATA[
|
|
<?php
|
|
/* OCIBindByPos example thies at thieso dot net (980221)
|
|
inserts 3 records into emp, and uses the ROWID for updating the
|
|
records just after the insert.
|
|
*/
|
|
|
|
$conn = OCILogon("scott", "tiger");
|
|
|
|
$stmt = OCIParse($conn, "insert into emp (empno, ename) " .
|
|
"values (:empno,:ename) " .
|
|
"returning ROWID into :rid");
|
|
|
|
$data = array(1111 => "Larry", 2222 => "Bill", 3333 => "Jim");
|
|
|
|
$rowid = OCINewDescriptor($conn, OCI_D_ROWID);
|
|
|
|
OCIBindByName($stmt, ":empno", $empno, 32);
|
|
OCIBindByName($stmt, ":ename", $ename, 32);
|
|
OCIBindByName($stmt, ":rid", $rowid, -1, OCI_B_ROWID);
|
|
|
|
$update = OCIParse($conn, "update emp set sal = :sal where ROWID = :rid");
|
|
OCIBindByName($update, ":rid", $rowid, -1, OCI_B_ROWID);
|
|
OCIBindByName($update, ":sal", $sal, 32);
|
|
|
|
$sal = 10000;
|
|
|
|
while (list($empno, $ename) = each($data)) {
|
|
OCIExecute($stmt);
|
|
OCIExecute($update);
|
|
}
|
|
|
|
$rowid->free();
|
|
|
|
OCIFreeStatement($update);
|
|
OCIFreeStatement($stmt);
|
|
|
|
$stmt = OCIParse($conn, "select * from emp where empno in (1111,2222,3333)");
|
|
OCIExecute($stmt);
|
|
while (OCIFetchInto($stmt, &$arr, OCI_ASSOC)) {
|
|
var_dump($arr);
|
|
}
|
|
OCIFreeStatement($stmt);
|
|
|
|
/* delete our "junk" from the emp table.... */
|
|
$stmt = OCIParse($conn, "delete from emp where empno in (1111,2222,3333)");
|
|
OCIExecute($stmt);
|
|
OCIFreeStatement($stmt);
|
|
|
|
OCILogoff($conn);
|
|
?>
|
|
]]>
|
|
</programlisting>
|
|
</example>
|
|
</para>
|
|
<note>
|
|
<para>
|
|
This function was renamed to <function>oci_bind_by_name</function>
|
|
after PHP >= 5.0.0. For downward compatibility
|
|
<function>ocibindbyname</function> can also be used.
|
|
This is deprecated, however.
|
|
</para>
|
|
</note>
|
|
<warning>
|
|
<para>
|
|
It is a bad idea to use magic quotes and
|
|
<function>ocibindbyname</function> simultaneously as no quoting
|
|
is needed on quoted variables and any quotes magically applied
|
|
will be written into your database as
|
|
<function>ocibindbyname</function> is not able to distinguish
|
|
magically added quotings from those added by intention.
|
|
</para>
|
|
</warning>
|
|
</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:"../../../../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
|
|
-->
|