<?php
include_once $_SERVER['DOCUMENT_ROOT'] . '/include/shared-manual.inc';
$TOC = array();
$TOC_DEPRECATED = array();
$PARENTS = array();
include_once dirname(__FILE__) ."/toc/class.pdostatement.inc";
$setup = array (
  'home' => 
  array (
    0 => 'index.php',
    1 => 'PHP Manual',
  ),
  'head' => 
  array (
    0 => 'UTF-8',
    1 => 'it',
  ),
  'this' => 
  array (
    0 => 'pdostatement.fetchobject.php',
    1 => 'PDOStatement::fetchObject',
    2 => 'Fetches the next row and returns it as an object',
  ),
  'up' => 
  array (
    0 => 'class.pdostatement.php',
    1 => 'PDOStatement',
  ),
  'prev' => 
  array (
    0 => 'pdostatement.fetchcolumn.php',
    1 => 'PDOStatement::fetchColumn',
  ),
  'next' => 
  array (
    0 => 'pdostatement.getattribute.php',
    1 => 'PDOStatement::getAttribute',
  ),
  'alternatives' => 
  array (
  ),
  'source' => 
  array (
    'lang' => 'en',
    'path' => 'reference/pdo/pdostatement/fetchobject.xml',
  ),
  'history' => 
  array (
  ),
);
$setup["toc"] = $TOC;
$setup["toc_deprecated"] = $TOC_DEPRECATED;
$setup["parents"] = $PARENTS;
manual_setup($setup);

contributors($setup);

?>
<div id="pdostatement.fetchobject" class="refentry">
 <div class="refnamediv">
  <h1 class="refname">PDOStatement::fetchObject</h1>
  <p class="verinfo">(PHP 5 &gt;= 5.1.0, PHP 7, PHP 8, PECL pdo &gt;= 0.2.4)</p><p class="refpurpose"><span class="refname">PDOStatement::fetchObject</span> &mdash; <span class="dc-title">Fetches the next row and returns it as an object</span></p>

 </div>
 <div class="refsect1 description" id="refsect1-pdostatement.fetchobject-description">
  <h3 class="title">Descrizione</h3>
  <div class="methodsynopsis dc-description">
   <span class="modifier">public</span> <span class="methodname"><strong>PDOStatement::fetchObject</strong></span>(<span class="methodparam"><span class="type"><span class="type"><a href="language.types.null.php" class="type null">?</a></span><span class="type"><a href="language.types.string.php" class="type string">string</a></span></span> <code class="parameter">$class</code><span class="initializer"> = &quot;stdClass&quot;</span></span>, <span class="methodparam"><span class="type"><a href="language.types.array.php" class="type array">array</a></span> <code class="parameter">$constructorArgs</code><span class="initializer"> = []</span></span>): <span class="type"><span class="type"><a href="language.types.object.php" class="type object">object</a></span>|<span class="type"><a href="language.types.singleton.php" class="type false">false</a></span></span></div>


  <p class="para rdfs-comment">
   Fetches the next row and returns it as an object. This function is an
   alternative to <span class="methodname"><a href="pdostatement.fetch.php" class="methodname">PDOStatement::fetch()</a></span> with
   <strong><code><a href="pdo.constants.fetch-modes.php#pdo.constants.fetch-class">PDO::FETCH_CLASS</a></code></strong> or
   <strong><code><a href="pdo.constants.fetch-modes.php#pdo.constants.fetch-obj">PDO::FETCH_OBJ</a></code></strong> style.
  </p>
  <p class="para">
   When an object is fetched, its properties are assigned from respective
   column values, and afterwards its constructor is invoked.
  </p>

 </div>

 <div class="refsect1 parameters" id="refsect1-pdostatement.fetchobject-parameters">
  <h3 class="title">Elenco dei parametri</h3>
  <p class="para">
   <dl>
    
     <dt><code class="parameter">class</code></dt>
     <dd>
      <p class="para">
       Name of the created class.
      </p>
     </dd>
    
    
     <dt><code class="parameter">constructorArgs</code></dt>
     <dd>
      <p class="para">
       Elements of this array are passed to the constructor.
      </p>
     </dd>
    
   </dl>
  </p>
 </div>

 <div class="refsect1 returnvalues" id="refsect1-pdostatement.fetchobject-returnvalues">
  <h3 class="title">Valori restituiti</h3>
  <p class="para">
   Returns an instance of the required class with property names that
   correspond to the column names  o <strong><code><a href="reserved.constants.php#constant.false">false</a></code></strong> in caso di fallimento.
  </p>
 </div>


 <div class="refsect1 errors" id="refsect1-pdostatement.fetchobject-errors">
  <h3 class="title">Errori/Eccezioni</h3>
  <p class="para">
Emits an error with level <strong><code><a href="errorfunc.constants.php#constant.e-warning">E_WARNING</a></code></strong> if the attribute <strong><code><a href="pdo.constants.php#pdo.constants.attr-errmode">PDO::ATTR_ERRMODE</a></code></strong> is set
to <strong><code><a href="pdo.constants.php#pdo.constants.errmode-warning">PDO::ERRMODE_WARNING</a></code></strong>.
</p>
<p class="para">
Throws a <span class="classname"><a href="class.pdoexception.php" class="classname">PDOException</a></span> if the attribute <strong><code><a href="pdo.constants.php#pdo.constants.attr-errmode">PDO::ATTR_ERRMODE</a></code></strong>
is set to <strong><code><a href="pdo.constants.php#pdo.constants.errmode-exception">PDO::ERRMODE_EXCEPTION</a></code></strong>.
</p>
 </div>


 <div class="refsect1 seealso" id="refsect1-pdostatement.fetchobject-seealso">
  <h3 class="title">Vedere anche:</h3>
  <p class="para">
   <ul class="simplelist">
    <li><span class="methodname"><a href="pdostatement.fetch.php" class="methodname" rel="rdfs-seeAlso">PDOStatement::fetch()</a> - Fetches the next row from a result set</span></li>
   </ul>
  </p>
 </div>



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