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
|
<?xml version="1.0" encoding="iso-8859-1"?>
<!-- $Revision: 1.7 $ -->
<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
case of error or there are no more rows in the result.
</para>
<para>
<function>oci_fetch_array</function> returns an array with both
associative and numeric indices.
</para>
&database.fetch-null;
<para>
An optional second parameter can be any combination of the following
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>
Oracle returns all field names in uppercase and associative indices in the result array will be uppercased too.
</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);
while ($row = oci_fetch_array ($statement, OCI_ASSOC)) {
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);
while ($row = oci_fetch_array ($statement, (OCI_NUM+OCI_RETURN_LOBS))) {
echo $row[0]."<br>";
echo $row[1]."<br>";
echo $row['LOB_FIELD']."<br>"; //this will output LOB's content
}
?>
]]>
</programlisting>
</example>
</para>
&oci.datatypes;
<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
-->
|