<?php
include_once $_SERVER['DOCUMENT_ROOT'] . '/include/shared-manual.inc';
$TOC = array();
$TOC_DEPRECATED = array();
$PARENTS = array();
include_once dirname(__FILE__) ."/toc/class.pdo.inc";
$setup = array (
  'home' => 
  array (
    0 => 'index.php',
    1 => 'PHP Manual',
  ),
  'head' => 
  array (
    0 => 'UTF-8',
    1 => 'it',
  ),
  'this' => 
  array (
    0 => 'pdo.setattribute.php',
    1 => 'PDO::setAttribute',
    2 => 'Set an attribute',
  ),
  'up' => 
  array (
    0 => 'class.pdo.php',
    1 => 'PDO',
  ),
  'prev' => 
  array (
    0 => 'pdo.rollback.php',
    1 => 'PDO::rollBack',
  ),
  'next' => 
  array (
    0 => 'class.pdostatement.php',
    1 => 'PDOStatement',
  ),
  'alternatives' => 
  array (
  ),
  'source' => 
  array (
    'lang' => 'en',
    'path' => 'reference/pdo/pdo/setattribute.xml',
  ),
  'history' => 
  array (
  ),
);
$setup["toc"] = $TOC;
$setup["toc_deprecated"] = $TOC_DEPRECATED;
$setup["parents"] = $PARENTS;
manual_setup($setup);

contributors($setup);

?>
<div id="pdo.setattribute" class="refentry">
 <div class="refnamediv">
  <h1 class="refname">PDO::setAttribute</h1>
  <p class="verinfo">(PHP 5 &gt;= 5.1.0, PHP 7, PHP 8, PECL pdo &gt;= 0.1.0)</p><p class="refpurpose"><span class="refname">PDO::setAttribute</span> &mdash; <span class="dc-title">
   Set an attribute
  </span></p>

 </div>
 <div class="refsect1 description" id="refsect1-pdo.setattribute-description">
  <h3 class="title">Descrizione</h3>
  <div class="methodsynopsis dc-description">
   <span class="modifier">public</span> <span class="methodname"><strong>PDO::setAttribute</strong></span>(<span class="methodparam"><span class="type"><a href="language.types.integer.php" class="type int">int</a></span> <code class="parameter">$attribute</code></span>, <span class="methodparam"><span class="type"><a href="language.types.mixed.php" class="type mixed">mixed</a></span> <code class="parameter">$value</code></span>): <span class="type"><a href="language.types.boolean.php" class="type bool">bool</a></span></div>


  <p class="para rdfs-comment">
   Sets an attribute on the database handle. Some available generic
   attributes are listed below; some drivers may make use of
   additional driver specific attributes.
   Note that driver specific attributes <em>must not</em> be used
   with other drivers.
   <dl>
    
     <dt><strong><code><a href="pdo.constants.php#pdo.constants.attr-case">PDO::ATTR_CASE</a></code></strong></dt>
     <dd>
      <p class="para">
       Force column names to a specific case.
       Can take one of the following values:
      </p>
      <dl>
       
        <dt><strong><code><a href="pdo.constants.php#pdo.constants.case-lower">PDO::CASE_LOWER</a></code></strong></dt>
        <dd>
         <span class="simpara">
          Force column names to lower case.
         </span>
        </dd>
       
       
        <dt><strong><code><a href="pdo.constants.php#pdo.constants.case-natural">PDO::CASE_NATURAL</a></code></strong></dt>
        <dd>
         <span class="simpara">
          Leave column names as returned by the database driver.
         </span>
        </dd>
       
       
        <dt><strong><code><a href="pdo.constants.php#pdo.constants.case-upper">PDO::CASE_UPPER</a></code></strong></dt>
        <dd>
         <span class="simpara">
          Force column names to upper case.
         </span>
        </dd>
       
      </dl>
     </dd>
    
    
     <dt><strong><code><a href="pdo.constants.php#pdo.constants.attr-errmode">PDO::ATTR_ERRMODE</a></code></strong></dt>
     <dd>
      <p class="para">
       Error reporting mode of PDO.
       Can take one of the following values:
      </p>
      <dl>
       
        <dt><strong><code><a href="pdo.constants.php#pdo.constants.errmode-silent">PDO::ERRMODE_SILENT</a></code></strong></dt>
        <dd>
         <span class="simpara">
          Only sets error codes.
         </span>
        </dd>
       
       
        <dt><strong><code><a href="pdo.constants.php#pdo.constants.errmode-warning">PDO::ERRMODE_WARNING</a></code></strong></dt>
        <dd>
         <span class="simpara">
          Raises <strong><code><a href="errorfunc.constants.php#constant.e-warning">E_WARNING</a></code></strong> diagnostics.
         </span>
        </dd>
       
       
        <dt><strong><code><a href="pdo.constants.php#pdo.constants.errmode-exception">PDO::ERRMODE_EXCEPTION</a></code></strong></dt>
        <dd>
         <span class="simpara">
          Throws <span class="classname"><a href="class.pdoexception.php" class="classname">PDOException</a></span>s.
         </span>
        </dd>
       
      </dl>
     </dd>
    
    
     <dt><strong><code><a href="pdo.constants.php#pdo.constants.attr-oracle-nulls">PDO::ATTR_ORACLE_NULLS</a></code></strong></dt>
     <dd>
      <blockquote class="note"><p><strong class="note">Nota</strong>: 
       <span class="simpara">
        This attribute is available with all drivers, not just Oracle.
       </span>
      </p></blockquote>
      <p class="para">
       Determines if and how <strong><code><a href="reserved.constants.php#constant.null">null</a></code></strong> and empty strings should be converted.
       Can take one of the following values:
      </p>
      <dl>
       
        <dt><strong><code><a href="pdo.constants.php#pdo.constants.null-natural">PDO::NULL_NATURAL</a></code></strong></dt>
        <dd>
         <span class="simpara">
          No conversion takes place.
         </span>
        </dd>
       
       
        <dt><strong><code><a href="pdo.constants.php#pdo.constants.null-empty-string">PDO::NULL_EMPTY_STRING</a></code></strong></dt>
        <dd>
         <span class="simpara">
          Empty strings get converted to <strong><code><a href="reserved.constants.php#constant.null">null</a></code></strong>.
         </span>
        </dd>
       
       
        <dt><strong><code><a href="pdo.constants.php#pdo.constants.null-to-string">PDO::NULL_TO_STRING</a></code></strong></dt>
        <dd>
         <span class="simpara">
          <strong><code><a href="reserved.constants.php#constant.null">null</a></code></strong> gets converted to an empty string.
         </span>
        </dd>
       
      </dl>
     </dd>
    
    
     <dt><strong><code><a href="pdo.constants.php#pdo.constants.attr-stringify-fetches">PDO::ATTR_STRINGIFY_FETCHES</a></code></strong></dt>
     <dd>
      <p class="para">
       Controls whether fetched values (except <strong><code><a href="reserved.constants.php#constant.null">null</a></code></strong>) are converted to strings.
       Takes a value of type <span class="type"><a href="language.types.boolean.php" class="type bool">bool</a></span>: <strong><code><a href="reserved.constants.php#constant.true">true</a></code></strong> to enable and <strong><code><a href="reserved.constants.php#constant.false">false</a></code></strong> to
       disable (default).
       <strong><code><a href="reserved.constants.php#constant.null">null</a></code></strong> values remain unchanged unless <strong><code><a href="pdo.constants.php#pdo.constants.attr-oracle-nulls">PDO::ATTR_ORACLE_NULLS</a></code></strong>
       is set to <strong><code><a href="pdo.constants.php#pdo.constants.null-to-string">PDO::NULL_TO_STRING</a></code></strong>.
      </p>
     </dd>
    
    
     <dt><strong><code><a href="pdo.constants.php#pdo.constants.attr-statement-class">PDO::ATTR_STATEMENT_CLASS</a></code></strong></dt>
     <dd>
      <p class="para">
       Set user-supplied statement class derived from PDOStatement.
       
       Requires <code class="literal">array(string classname, array(mixed constructor_args))</code>.
      </p>
      <div class="caution"><strong class="caution">Attenzione</strong>
       <p class="simpara">
        Cannot be used with persistent PDO instances.
       </p>
      </div>
     </dd>
    
    
     <dt><strong><code><a href="pdo.constants.php#pdo.constants.attr-timeout">PDO::ATTR_TIMEOUT</a></code></strong></dt>
     <dd>
      <p class="para">
       Specifies the timeout duration in seconds.
       Takes a value of type <span class="type"><a href="language.types.integer.php" class="type int">int</a></span>.
      </p>
      <blockquote class="note"><p><strong class="note">Nota</strong>: 
       <p class="para">
        Not all drivers support this option, and its meaning may differ from
        driver to driver. For example, SQLite will wait for up to this time
        value before giving up on obtaining a writable lock, but other drivers
        may interpret this as a connection or a read timeout interval.
       </p>
      </p></blockquote>
     </dd>
    
    
     <dt><strong><code><a href="pdo.constants.php#pdo.constants.attr-autocommit">PDO::ATTR_AUTOCOMMIT</a></code></strong></dt>
     <dd>
      <blockquote class="note"><p><strong class="note">Nota</strong>: 
       <span class="simpara">
        Only available for the OCI, Firebird, and MySQL drivers.
       </span>
      </p></blockquote>
      <p class="para">
       Whether to autocommit every single statement.
       Takes a value of type <span class="type"><a href="language.types.boolean.php" class="type bool">bool</a></span>: <strong><code><a href="reserved.constants.php#constant.true">true</a></code></strong> to enable and
       <strong><code><a href="reserved.constants.php#constant.false">false</a></code></strong> to disable. By default, <strong><code><a href="reserved.constants.php#constant.true">true</a></code></strong>.
      </p>
     </dd>
    
    
     <dt><strong><code><a href="pdo.constants.php#pdo.constants.attr-emulate-prepares">PDO::ATTR_EMULATE_PREPARES</a></code></strong></dt>
     <dd>
      <blockquote class="note"><p><strong class="note">Nota</strong>: 
       <span class="simpara">
        Only available for the OCI, Firebird, and MySQL drivers.
       </span>
      </p></blockquote>
      <p class="para">
       Whether enable or disable emulation of prepared statements.
       Some drivers do not support prepared statements natively or have
       limited support for them.
       If set to <strong><code><a href="reserved.constants.php#constant.true">true</a></code></strong> PDO will always emulate prepared statements,
       otherwise PDO will attempt to use native prepared statements.
       In case the driver cannot successfully prepare the current query,
       PDO will always fall back to emulating the prepared statement.
      </p>
     </dd>
    
    
     <dt><strong><code><a href="ref.pdo-mysql.php#pdo.constants.mysql-attr-use-buffered-query">PDO::MYSQL_ATTR_USE_BUFFERED_QUERY</a></code></strong></dt>
     <dd>
      <blockquote class="note"><p><strong class="note">Nota</strong>: 
       <span class="simpara">
        Only available for the MySQL driver.
       </span>
      </p></blockquote>
      <p class="para">
       Whether to use buffered queries.
       Takes a value of type <span class="type"><a href="language.types.boolean.php" class="type bool">bool</a></span>: <strong><code><a href="reserved.constants.php#constant.true">true</a></code></strong> to enable and
       <strong><code><a href="reserved.constants.php#constant.false">false</a></code></strong> to disable. By default, <strong><code><a href="reserved.constants.php#constant.true">true</a></code></strong>.
      </p>
     </dd>
    
    
     <dt><strong><code><a href="pdo.constants.php#pdo.constants.attr-default-fetch-mode">PDO::ATTR_DEFAULT_FETCH_MODE</a></code></strong></dt>
     <dd>
      <p class="para">
       Set the default fetch mode.
       A description of the modes and how to use them is available in the
       <span class="methodname"><a href="pdostatement.fetch.php" class="methodname">PDOStatement::fetch()</a></span> documentation.
      </p>
     </dd>
    
   </dl>
  </p>
 </div>


 <div class="refsect1 parameters" id="refsect1-pdo.setattribute-parameters">
  <h3 class="title">Elenco dei parametri</h3>
  <p class="para">
   <dl>
    
     <dt><code class="parameter">attribute</code></dt>
     <dd>
      <p class="para">
       The attribute to modify.
      </p>
     </dd>
    
    
     <dt><code class="parameter">value</code></dt>
     <dd>
      <p class="para">
       The value to set the <code class="parameter">attribute</code>,
       might require a specific type depending on the attribute.
      </p>
     </dd>
    
   </dl>
  </p>
 </div>


 <div class="refsect1 returnvalues" id="refsect1-pdo.setattribute-returnvalues">
  <h3 class="title">Valori restituiti</h3>
  <p class="para">
   Restituisce <strong><code><a href="reserved.constants.php#constant.true">true</a></code></strong> in caso di successo, <strong><code><a href="reserved.constants.php#constant.false">false</a></code></strong> in caso di fallimento.
  </p>
 </div>


 <div class="refsect1 seealso" id="refsect1-pdo.setattribute-seealso">
  <h3 class="title">Vedere anche:</h3>
  <p class="para">
   <ul class="simplelist">
    <li><span class="function"><a href="pdo.getattribute.php" class="function" rel="rdfs-seeAlso">PDO::getAttribute()</a> - Retrieve a database connection attribute</span></li>
    <li><span class="function"><a href="pdostatement.getattribute.php" class="function" rel="rdfs-seeAlso">PDOStatement::getAttribute()</a> - Retrieve a statement attribute</span></li>
    <li><span class="function"><a href="pdostatement.setattribute.php" class="function" rel="rdfs-seeAlso">PDOStatement::setAttribute()</a> - Set a statement attribute</span></li>
   </ul>
  </p>
 </div>


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