<?php
include_once $_SERVER['DOCUMENT_ROOT'] . '/include/shared-manual.inc';
$TOC = array();
$TOC_DEPRECATED = array();
$PARENTS = array();
include_once dirname(__FILE__) ."/toc/ref.oci8.inc";
$setup = array (
  'home' => 
  array (
    0 => 'index.php',
    1 => 'PHP Manual',
  ),
  'head' => 
  array (
    0 => 'UTF-8',
    1 => 'de',
  ),
  'this' => 
  array (
    0 => 'function.oci-fetch-object.php',
    1 => 'oci_fetch_object',
    2 => 'Liefert die n&auml;chste Zeile einer Abfrage als Objekt',
  ),
  'up' => 
  array (
    0 => 'ref.oci8.php',
    1 => 'OCI8 Funktionen',
  ),
  'prev' => 
  array (
    0 => 'function.oci-fetch-assoc.php',
    1 => 'oci_fetch_assoc',
  ),
  'next' => 
  array (
    0 => 'function.oci-fetch-row.php',
    1 => 'oci_fetch_row',
  ),
  'alternatives' => 
  array (
  ),
  'source' => 
  array (
    'lang' => 'de',
    'path' => 'reference/oci8/functions/oci-fetch-object.xml',
  ),
  'history' => 
  array (
  ),
);
$setup["toc"] = $TOC;
$setup["toc_deprecated"] = $TOC_DEPRECATED;
$setup["parents"] = $PARENTS;
manual_setup($setup);

contributors($setup);

?>
<div id="function.oci-fetch-object" class="refentry">
 <div class="refnamediv">
  <h1 class="refname">oci_fetch_object</h1>
  <p class="verinfo">(PHP 5, PHP 7, PHP 8, PECL OCI8 &gt;= 1.1.0)</p><p class="refpurpose"><span class="refname">oci_fetch_object</span> &mdash; <span class="dc-title">Liefert die nächste Zeile einer Abfrage als Objekt</span></p>

 </div>

 <div class="refsect1 description" id="refsect1-function.oci-fetch-object-description">
  <h3 class="title">Beschreibung</h3>
  <div class="methodsynopsis dc-description">
   <span class="methodname"><strong>oci_fetch_object</strong></span>(<span class="methodparam"><span class="type"><a href="language.types.resource.php" class="type resource">resource</a></span> <code class="parameter">$statement</code></span>, <span class="methodparam"><span class="type"><a href="language.types.integer.php" class="type int">int</a></span> <code class="parameter">$mode</code><span class="initializer"> = OCI_ASSOC | OCI_RETURN_NULLS</span></span>): <span class="type"><span class="type"><a href="class.stdclass.php" class="type stdClass">stdClass</a></span>|<span class="type"><a href="language.types.singleton.php" class="type false">false</a></span></span></div>

  <p class="para rdfs-comment">
   Gibt ein Objekt zurück, das die nächste Zeile der Ergebnismenge einer
   Abfrage enthält. Jede Eigenschaft des Objekts entspricht einer Spalte der
   Zeile. Diese Funktion wird üblicherweise in einer Schleife aufgerufen bis
   sie <strong><code><a href="reserved.constants.php#constant.false">false</a></code></strong> zurückgibt, was anzeigt, dass es keine weitere Zeilen gibt.
  </p>
  <p class="para">Für Details zur vom OCI8-Treiber durchgeführten
Umsetzung von Datentypen siehe die
<a href="oci8.datatypes.php" class="link">vom Treiber unterstützen Datentypen</a>.</p>
 </div>


 <div class="refsect1 parameters" id="refsect1-function.oci-fetch-object-parameters">
  <h3 class="title">Parameter-Liste</h3>
  <p class="para">
   <dl>
    
     <dt><code class="parameter">statement</code></dt>
     <dd>
      <p class="para">Der Identifizierer eines
gültigen OCI8-Ausdrucks, der von <span class="function"><a href="function.oci-parse.php" class="function">oci_parse()</a></span> erzeugt
und von <span class="function"><a href="function.oci-execute.php" class="function">oci_execute()</a></span> oder einem <code class="literal">REF
CURSOR</code>-Ausdruck verwendet wird.</p>
     </dd>
    
   </dl>
  </p>
 </div>


 <div class="refsect1 returnvalues" id="refsect1-function.oci-fetch-object-returnvalues">
  <h3 class="title">Rückgabewerte</h3>
  <p class="para">
   Gibt ein Objekt zurück. Jede Eigenschaft des Objekts entspricht einer
   Spalte der Zeile. Gibt es keine weiteren Zeilen in
   <code class="parameter">statement</code>, dann wird <strong><code><a href="reserved.constants.php#constant.false">false</a></code></strong> zurückgegeben.
  </p>
  <p class="para">
   Jegliche <code class="literal">LOB</code>-Spalten werden als LOB-Kennungen
   zurückgegeben.
  </p>
  <p class="para">
   <code class="literal">DATE</code>-Spalten werden als gemäß des aktuellen
   Datumsformats formatierte Zeichenketten zurückgegeben. Das Standardformat
   kann mit Oracle-Umgebungsvariablen wie <code class="literal">NLS_LANG</code> geändert
   werden oder auch durch den zuvor ausgeführten Befehl <code class="literal">ALTER
   SESSION SET NLS_DATE_FORMAT</code>.
  </p>
  <p class="para">
   Die standardmäßigen Oracle-Spaltennamen, die nicht zwischen Groß- und
   Kleinschreibung unterscheiden, erzeugen Eigenschaftsnamen in
   Großbuchstaben. Spaltennamen, die zwischen Groß- und Kleinschreibung
   unterscheiden, verwenden die genaue Schreibweise.
   <span class="function"><a href="function.var-dump.php" class="function">var_dump()</a></span> kann auf das Ergebnisobjekt angewendet
   werden, um die richtige Schreibweise für den Eigenschaftszugriff zu prüfen.
  </p>
  <p class="para">
   Die Eigenschaftswerte sind <strong><code><a href="reserved.constants.php#constant.null">null</a></code></strong> für jegliche
   <code class="literal">NULL</code>-Datenfelder.
  </p>
 </div>


 <div class="refsect1 examples" id="refsect1-function.oci-fetch-object-examples">
  <h3 class="title">Beispiele</h3>
  <p class="para">
   <div class="example" id="example-1">
    <p><strong>Beispiel #1 <span class="function"><strong>oci_fetch_object()</strong></span>-Beispiel</strong></p>
    <div class="example-contents">
<div class="phpcode"><code><span style="color: #000000"><span style="color: #0000BB">&lt;?php<br /><br /></span><span style="color: #FF8000">/*<br />  Vor der Ausführung ist die Tabelle zu erstellen:<br />    CREATE TABLE mytab (id NUMBER, description VARCHAR2(30));<br />    INSERT INTO mytab (id, description) values (1, 'Currywurst mit Pommes');<br />    COMMIT;<br />*/<br /><br /></span><span style="color: #0000BB">$conn </span><span style="color: #007700">= </span><span style="color: #0000BB">oci_connect</span><span style="color: #007700">(</span><span style="color: #DD0000">'hr'</span><span style="color: #007700">, </span><span style="color: #DD0000">'welcome'</span><span style="color: #007700">, </span><span style="color: #DD0000">'localhost/XE'</span><span style="color: #007700">);<br />if (!</span><span style="color: #0000BB">$conn</span><span style="color: #007700">) {<br />    </span><span style="color: #0000BB">$e </span><span style="color: #007700">= </span><span style="color: #0000BB">oci_error</span><span style="color: #007700">();<br />    </span><span style="color: #0000BB">trigger_error</span><span style="color: #007700">(</span><span style="color: #0000BB">htmlentities</span><span style="color: #007700">(</span><span style="color: #0000BB">$e</span><span style="color: #007700">[</span><span style="color: #DD0000">'message'</span><span style="color: #007700">], </span><span style="color: #0000BB">ENT_QUOTES</span><span style="color: #007700">), </span><span style="color: #0000BB">E_USER_ERROR</span><span style="color: #007700">);<br />}<br /><br /></span><span style="color: #0000BB">$stid </span><span style="color: #007700">= </span><span style="color: #0000BB">oci_parse</span><span style="color: #007700">(</span><span style="color: #0000BB">$conn</span><span style="color: #007700">, </span><span style="color: #DD0000">'SELECT id, description FROM mytab'</span><span style="color: #007700">);<br /></span><span style="color: #0000BB">oci_execute</span><span style="color: #007700">(</span><span style="color: #0000BB">$stid</span><span style="color: #007700">);<br /><br />while ((</span><span style="color: #0000BB">$row </span><span style="color: #007700">= </span><span style="color: #0000BB">oci_fetch_object</span><span style="color: #007700">(</span><span style="color: #0000BB">$stid</span><span style="color: #007700">)) != </span><span style="color: #0000BB">false</span><span style="color: #007700">) {<br />    </span><span style="color: #FF8000">// verwende Eigenschaftsnamen in Großschrift für jede Standard-Oracle-Spalte<br />    </span><span style="color: #007700">echo </span><span style="color: #0000BB">$row</span><span style="color: #007700">-&gt;</span><span style="color: #0000BB">ID </span><span style="color: #007700">. </span><span style="color: #DD0000">"&lt;br&gt;\n"</span><span style="color: #007700">;<br />    echo </span><span style="color: #0000BB">$row</span><span style="color: #007700">-&gt;</span><span style="color: #0000BB">DESCRIPTION </span><span style="color: #007700">. </span><span style="color: #DD0000">"&lt;br&gt;\n"</span><span style="color: #007700">;<br />}<br /><br /></span><span style="color: #FF8000">// Ausgabe:<br />//    1<br />//    Currywurst mit Pommes<br /><br /></span><span style="color: #0000BB">oci_free_statement</span><span style="color: #007700">(</span><span style="color: #0000BB">$stid</span><span style="color: #007700">);<br /></span><span style="color: #0000BB">oci_close</span><span style="color: #007700">(</span><span style="color: #0000BB">$conn</span><span style="color: #007700">);<br /><br /></span><span style="color: #0000BB">?&gt;</span></span></code></div>
    </div>

   </div>
  </p>
  <p class="para">
   <div class="example" id="example-2">
    <p><strong>Beispiel #2 
     <span class="function"><strong>oci_fetch_object()</strong></span> mit Spaltennamen, die zwischen
     Groß- und Kleinschreibung unterscheiden.
    </strong></p>
    <div class="example-contents">
<div class="phpcode"><code><span style="color: #000000"><span style="color: #0000BB">&lt;?php<br /><br /></span><span style="color: #FF8000">/*<br />  Vor der Ausführung ist die Tabelle mit Spaltennamen, die zwischen Groß- und<br />  Kleinschreibung unterscheiden, zu erstellen:<br />    CREATE TABLE mytab (id NUMBER, "MyDescription" VARCHAR2(30));<br />    INSERT INTO mytab (id, "MyDescription") values (1, 'Eiskaffee');<br />    COMMIT;<br />*/<br /><br /></span><span style="color: #0000BB">$conn </span><span style="color: #007700">= </span><span style="color: #0000BB">oci_connect</span><span style="color: #007700">(</span><span style="color: #DD0000">'hr'</span><span style="color: #007700">, </span><span style="color: #DD0000">'welcome'</span><span style="color: #007700">, </span><span style="color: #DD0000">'localhost/XE'</span><span style="color: #007700">);<br />if (!</span><span style="color: #0000BB">$conn</span><span style="color: #007700">) {<br />    </span><span style="color: #0000BB">$e </span><span style="color: #007700">= </span><span style="color: #0000BB">oci_error</span><span style="color: #007700">();<br />    </span><span style="color: #0000BB">trigger_error</span><span style="color: #007700">(</span><span style="color: #0000BB">htmlentities</span><span style="color: #007700">(</span><span style="color: #0000BB">$e</span><span style="color: #007700">[</span><span style="color: #DD0000">'message'</span><span style="color: #007700">], </span><span style="color: #0000BB">ENT_QUOTES</span><span style="color: #007700">), </span><span style="color: #0000BB">E_USER_ERROR</span><span style="color: #007700">);<br />}<br /><br /></span><span style="color: #0000BB">$stid </span><span style="color: #007700">= </span><span style="color: #0000BB">oci_parse</span><span style="color: #007700">(</span><span style="color: #0000BB">$conn</span><span style="color: #007700">, </span><span style="color: #DD0000">'SELECT id, "MyDescription" FROM mytab'</span><span style="color: #007700">);<br /></span><span style="color: #0000BB">oci_execute</span><span style="color: #007700">(</span><span style="color: #0000BB">$stid</span><span style="color: #007700">);<br /><br />while ((</span><span style="color: #0000BB">$row </span><span style="color: #007700">= </span><span style="color: #0000BB">oci_fetch_object</span><span style="color: #007700">(</span><span style="color: #0000BB">$stid</span><span style="color: #007700">)) != </span><span style="color: #0000BB">false</span><span style="color: #007700">) {<br />    </span><span style="color: #FF8000">// verwende Eigenschaftsnamen in Großschrift für jede Standard-Oracle-Spalte<br />    </span><span style="color: #007700">echo </span><span style="color: #0000BB">$row</span><span style="color: #007700">-&gt;</span><span style="color: #0000BB">ID </span><span style="color: #007700">. </span><span style="color: #DD0000">"&lt;br&gt;\n"</span><span style="color: #007700">;<br />    </span><span style="color: #FF8000">// verwende die genaue Schreibweise für Spaltennamen, die zwischen Groß-<br />    // und Kleinschreibung unterscheiden<br />    </span><span style="color: #007700">echo </span><span style="color: #0000BB">$row</span><span style="color: #007700">-&gt;</span><span style="color: #0000BB">MyDescription </span><span style="color: #007700">. </span><span style="color: #DD0000">"&lt;br&gt;\n"</span><span style="color: #007700">;<br />}<br /><br /></span><span style="color: #FF8000">// Ausgabe:<br />//    1<br />//    Eiskaffee<br /><br /></span><span style="color: #0000BB">oci_free_statement</span><span style="color: #007700">(</span><span style="color: #0000BB">$stid</span><span style="color: #007700">);<br /></span><span style="color: #0000BB">oci_close</span><span style="color: #007700">(</span><span style="color: #0000BB">$conn</span><span style="color: #007700">);<br /><br /></span><span style="color: #0000BB">?&gt;</span></span></code></div>
    </div>

   </div>
  </p>
  <p class="para">
   <div class="example" id="example-3">
    <p><strong>Beispiel #3 <span class="function"><strong>oci_fetch_object()</strong></span> mit LOBs</strong></p>
    <div class="example-contents">
<div class="phpcode"><code><span style="color: #000000"><span style="color: #0000BB">&lt;?php<br /><br /></span><span style="color: #FF8000">/*<br />  Vor der Ausführung ist die Tabelle zu erstellen:<br />    CREATE TABLE mytab (id NUMBER, description CLOB);<br />    INSERT INTO mytab (id, description) values (1, 'Eine sehr lange Zeichenkette');<br />    COMMIT;<br />*/<br /><br /></span><span style="color: #0000BB">$conn </span><span style="color: #007700">= </span><span style="color: #0000BB">oci_connect</span><span style="color: #007700">(</span><span style="color: #DD0000">'hr'</span><span style="color: #007700">, </span><span style="color: #DD0000">'welcome'</span><span style="color: #007700">, </span><span style="color: #DD0000">'localhost/XE'</span><span style="color: #007700">);<br />if (!</span><span style="color: #0000BB">$conn</span><span style="color: #007700">) {<br />    </span><span style="color: #0000BB">$e </span><span style="color: #007700">= </span><span style="color: #0000BB">oci_error</span><span style="color: #007700">();<br />    </span><span style="color: #0000BB">trigger_error</span><span style="color: #007700">(</span><span style="color: #0000BB">htmlentities</span><span style="color: #007700">(</span><span style="color: #0000BB">$e</span><span style="color: #007700">[</span><span style="color: #DD0000">'message'</span><span style="color: #007700">], </span><span style="color: #0000BB">ENT_QUOTES</span><span style="color: #007700">), </span><span style="color: #0000BB">E_USER_ERROR</span><span style="color: #007700">);<br />}<br /><br /></span><span style="color: #0000BB">$stid </span><span style="color: #007700">= </span><span style="color: #0000BB">oci_parse</span><span style="color: #007700">(</span><span style="color: #0000BB">$conn</span><span style="color: #007700">, </span><span style="color: #DD0000">'SELECT id, description FROM mytab'</span><span style="color: #007700">);<br /></span><span style="color: #0000BB">oci_execute</span><span style="color: #007700">(</span><span style="color: #0000BB">$stid</span><span style="color: #007700">);<br /><br />while ((</span><span style="color: #0000BB">$row </span><span style="color: #007700">= </span><span style="color: #0000BB">oci_fetch_object</span><span style="color: #007700">(</span><span style="color: #0000BB">$stid</span><span style="color: #007700">)) != </span><span style="color: #0000BB">false</span><span style="color: #007700">) {<br />    echo </span><span style="color: #0000BB">$row</span><span style="color: #007700">-&gt;</span><span style="color: #0000BB">ID </span><span style="color: #007700">. </span><span style="color: #DD0000">"&lt;br&gt;\n"</span><span style="color: #007700">;<br />    </span><span style="color: #FF8000">// das folgende gibt die ersten 15 Bytes von DESCRIPTION aus<br />    </span><span style="color: #007700">echo </span><span style="color: #0000BB">$row</span><span style="color: #007700">-&gt;</span><span style="color: #0000BB">DESCRIPTION</span><span style="color: #007700">-&gt;</span><span style="color: #0000BB">read</span><span style="color: #007700">(</span><span style="color: #0000BB">15</span><span style="color: #007700">) . </span><span style="color: #DD0000">"&lt;br&gt;\n"</span><span style="color: #007700">;<br />}<br /><br /></span><span style="color: #FF8000">// Ausgabe:<br />//    1<br />//    Eine sehr lange<br /><br /></span><span style="color: #0000BB">oci_free_statement</span><span style="color: #007700">(</span><span style="color: #0000BB">$stid</span><span style="color: #007700">);<br /></span><span style="color: #0000BB">oci_close</span><span style="color: #007700">(</span><span style="color: #0000BB">$conn</span><span style="color: #007700">);<br /><br /></span><span style="color: #0000BB">?&gt;</span></span></code></div>
    </div>

   </div>
  </p>
 </div>


 <div class="refsect1 seealso" id="refsect1-function.oci-fetch-object-seealso">
  <h3 class="title">Siehe auch</h3>
  <p class="para">
   <ul class="simplelist">
    <li><span class="function"><a href="function.oci-fetch.php" class="function" rel="rdfs-seeAlso">oci_fetch()</a> - Ruft die n&auml;chste Zeile einer Abfrage in einen internen Puffer ab</span></li>
    <li><span class="function"><a href="function.oci-fetch-all.php" class="function" rel="rdfs-seeAlso">oci_fetch_all()</a> - Ruft mehrere Datens&auml;tze einer Abfrage in ein zweidimensionales Array ab</span></li>
    <li><span class="function"><a href="function.oci-fetch-assoc.php" class="function" rel="rdfs-seeAlso">oci_fetch_assoc()</a> - Liefert die n&auml;chste Zeile einer Abfrage als assoziatives Array</span></li>
    <li><span class="function"><a href="function.oci-fetch-array.php" class="function" rel="rdfs-seeAlso">oci_fetch_array()</a> - Liefert die n&auml;chste Zeile einer Abfrage als assoziatives oder numerisches Array</span></li>
    <li><span class="function"><a href="function.oci-fetch-row.php" class="function" rel="rdfs-seeAlso">oci_fetch_row()</a> - Liefert die n&auml;chste Zeile einer Abfrage als numerisches Array</span></li>
   </ul>
  </p>
 </div>


</div><?php manual_footer($setup); ?>