2005-09-07 09:35:22 +00:00
|
|
|
<?xml version="1.0" encoding="iso-8859-1"?>
|
2006-08-24 11:40:46 +00:00
|
|
|
<!-- $Revision: 1.7 $ -->
|
2004-03-08 14:12:17 +00:00
|
|
|
<refentry id="function.oci-fetch-array">
|
|
|
|
<refnamediv>
|
|
|
|
<refname>oci_fetch_array</refname>
|
|
|
|
<refpurpose>Returns the next row from the result data as an associative or
|
|
|
|
numeric array, or both
|
|
|
|
</refpurpose>
|
|
|
|
</refnamediv>
|
|
|
|
<refsect1>
|
|
|
|
<title>Description</title>
|
|
|
|
<methodsynopsis>
|
|
|
|
<type>array</type><methodname>oci_fetch_array</methodname>
|
|
|
|
<methodparam><type>resource</type><parameter>statement</parameter></methodparam>
|
|
|
|
<methodparam choice="opt"><type>int</type><parameter>mode</parameter></methodparam>
|
|
|
|
</methodsynopsis>
|
|
|
|
<para>
|
|
|
|
Returns an array, which corresponds to the next result row or &false; in
|
2005-09-06 20:18:30 +00:00
|
|
|
case of error or there are no more rows in the result.
|
2004-03-08 14:12:17 +00:00
|
|
|
</para>
|
|
|
|
<para>
|
|
|
|
<function>oci_fetch_array</function> returns an array with both
|
|
|
|
associative and numeric indices.
|
|
|
|
</para>
|
2004-07-26 14:02:10 +00:00
|
|
|
&database.fetch-null;
|
2004-03-08 14:12:17 +00:00
|
|
|
<para>
|
2005-09-06 20:18:30 +00:00
|
|
|
An optional second parameter can be any combination of the following
|
2004-03-08 14:12:17 +00:00
|
|
|
constants:
|
|
|
|
<simplelist>
|
|
|
|
<member>
|
|
|
|
<constant>OCI_BOTH</constant> - return an array with both associative
|
|
|
|
and numeric indices (the same as <constant>OCI_ASSOC</constant>
|
|
|
|
+ <constant>OCI_NUM</constant>). This is the default behavior.
|
|
|
|
</member>
|
|
|
|
<member>
|
|
|
|
<constant>OCI_ASSOC</constant> - return an associative array
|
|
|
|
(as <function>oci_fetch_assoc</function> works).
|
|
|
|
</member>
|
|
|
|
<member>
|
|
|
|
<constant>OCI_NUM</constant> - return a numeric array,
|
|
|
|
(as <function>oci_fetch_row</function> works).
|
|
|
|
</member>
|
|
|
|
<member>
|
|
|
|
<constant>OCI_RETURN_NULLS</constant> - create empty elements
|
|
|
|
for the &null; fields.
|
|
|
|
</member>
|
|
|
|
<member>
|
|
|
|
<constant>OCI_RETURN_LOBS</constant> - return the value of a LOB
|
|
|
|
of the descriptor.
|
|
|
|
</member>
|
|
|
|
</simplelist>
|
|
|
|
Default <parameter>mode</parameter> is <constant>OCI_BOTH</constant>.
|
|
|
|
</para>
|
|
|
|
<para>
|
|
|
|
It should be mentioned here, that <function>oci_fetch_array</function>
|
|
|
|
is <emphasis>insignificantly</emphasis> slower, than
|
|
|
|
<function>oci_fetch_row</function>, but much more handy.
|
|
|
|
</para>
|
|
|
|
<note>
|
|
|
|
<simpara>
|
2005-09-06 20:18:30 +00:00
|
|
|
Oracle returns all field names in uppercase and associative indices in the result array will be uppercased too.
|
2004-03-08 14:12:17 +00:00
|
|
|
</simpara>
|
|
|
|
</note>
|
|
|
|
<para>
|
|
|
|
<example>
|
|
|
|
<title><function>oci_fetch_array</function> with <constant>OCI_BOTH</constant> example</title>
|
|
|
|
<programlisting role="php">
|
|
|
|
<![CDATA[
|
|
|
|
<?php
|
|
|
|
$connection = oci_connect("apelsin", "kanistra");
|
|
|
|
|
|
|
|
$query = "SELECT id, name FROM fruits";
|
|
|
|
|
|
|
|
$statement = oci_parse ($connection, $query);
|
|
|
|
oci_execute ($statement);
|
|
|
|
|
|
|
|
while ($row = oci_fetch_array ($statement, OCI_BOTH)) {
|
|
|
|
echo $row[0]." and ".$row['ID']." is the same<br>";
|
|
|
|
echo $row[1]." and ".$row['NAME']." is the same<br>";
|
|
|
|
}
|
|
|
|
?>
|
|
|
|
]]>
|
|
|
|
</programlisting>
|
|
|
|
</example>
|
|
|
|
</para>
|
|
|
|
<para>
|
|
|
|
<example>
|
|
|
|
<title><function>oci_fetch_array</function> with
|
|
|
|
<constant>OCI_NUM</constant> example</title>
|
|
|
|
<programlisting role="php">
|
|
|
|
<![CDATA[
|
|
|
|
<?php
|
|
|
|
$connection = oci_connect("user", "password");
|
|
|
|
|
|
|
|
$query = "SELECT id, name, lob_field FROM fruits";
|
|
|
|
|
|
|
|
$statement = oci_parse ($connection, $query);
|
|
|
|
oci_execute ($statement);
|
|
|
|
|
|
|
|
while ($row = oci_fetch_array ($statement, OCI_NUM)) {
|
|
|
|
echo $row[0]."<br>";
|
|
|
|
echo $row[1]."<br>";
|
|
|
|
echo $row[2]->read(100)."<br>"; //this will output first 100 bytes from LOB
|
|
|
|
}
|
|
|
|
?>
|
|
|
|
]]>
|
|
|
|
</programlisting>
|
|
|
|
</example>
|
|
|
|
</para>
|
|
|
|
<para>
|
|
|
|
<example>
|
|
|
|
<title><function>oci_fetch_array</function> with
|
|
|
|
<constant>OCI_ASSOC</constant> example</title>
|
|
|
|
<programlisting role="php">
|
|
|
|
<![CDATA[
|
|
|
|
<?php
|
|
|
|
$connection = oci_connect("user", "password");
|
|
|
|
|
|
|
|
$query = "SELECT id, name, lob_field FROM fruits";
|
|
|
|
|
|
|
|
$statement = oci_parse ($connection, $query);
|
|
|
|
oci_execute ($statement);
|
|
|
|
|
2006-08-24 11:40:46 +00:00
|
|
|
while ($row = oci_fetch_array ($statement, OCI_ASSOC)) {
|
2004-03-08 14:12:17 +00:00
|
|
|
echo $row['ID']."<br>";
|
|
|
|
echo $row['NAME']."<br>";
|
|
|
|
echo $row['LOB_FIELD']."<br>"; //this will output "Object id #1"
|
|
|
|
}
|
|
|
|
?>
|
|
|
|
]]>
|
|
|
|
</programlisting>
|
|
|
|
</example>
|
|
|
|
</para>
|
|
|
|
<para>
|
|
|
|
<example>
|
|
|
|
<title><function>oci_fetch_array</function> with
|
|
|
|
<constant>OCI_RETURN_LOBS</constant> example</title>
|
|
|
|
<programlisting role="php">
|
|
|
|
<![CDATA[
|
|
|
|
<?php
|
|
|
|
$connection = oci_connect("user", "password");
|
|
|
|
|
|
|
|
$query = "SELECT id, name, lob_field FROM fruits";
|
|
|
|
|
|
|
|
$statement = oci_parse ($connection, $query);
|
|
|
|
oci_execute ($statement);
|
|
|
|
|
2006-08-24 11:40:46 +00:00
|
|
|
while ($row = oci_fetch_array ($statement, (OCI_NUM+OCI_RETURN_LOBS))) {
|
2004-03-08 14:12:17 +00:00
|
|
|
echo $row[0]."<br>";
|
|
|
|
echo $row[1]."<br>";
|
|
|
|
echo $row['LOB_FIELD']."<br>"; //this will output LOB's content
|
|
|
|
}
|
|
|
|
?>
|
|
|
|
]]>
|
|
|
|
</programlisting>
|
|
|
|
</example>
|
|
|
|
</para>
|
2005-09-06 20:41:30 +00:00
|
|
|
&oci.datatypes;
|
2004-03-08 14:12:17 +00:00
|
|
|
<para>
|
|
|
|
See also <function>oci_fetch_assoc</function>,
|
|
|
|
<function>oci_fetch_object</function>,
|
|
|
|
<function>oci_fetch_row</function> and
|
|
|
|
<function>oci_fetch_all</function>.
|
|
|
|
</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:"../../../../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
|
|
|
|
-->
|
2005-09-06 20:18:30 +00:00
|
|
|
|