<?xml version="1.0" encoding="utf-8"?>
<!-- $Revision$ -->
<refentry xml:id="pdo.getattribute" xmlns="http://docbook.org/ns/docbook">
 <refnamediv>
  <refname>PDO::getAttribute</refname>
  <refpurpose>
   Retrieve a database connection attribute
  </refpurpose>
 </refnamediv>
 <refsect1 role="description">
  &reftitle.description;
  <methodsynopsis role="PDO">
   <modifier>public</modifier> <type>mixed</type><methodname>PDO::getAttribute</methodname>
   <methodparam><type>int</type><parameter>attribute</parameter></methodparam>
  </methodsynopsis>

  <para>
   This function returns the value of a database connection attribute. To
   retrieve PDOStatement attributes, refer to
   <methodname>PDOStatement::getAttribute</methodname>.
  </para>

  <para>
   Note that some database/driver combinations may not support all of the
   database connection attributes.
  </para>

 </refsect1>

 <refsect1 role="parameters">
  &reftitle.parameters;
  <para>
   <variablelist>
    <varlistentry>
     <term><parameter>attribute</parameter></term>
     <listitem>
      <para>
       One of the <literal>PDO::ATTR_*</literal> constants. The generic attributes that
       apply to database connections are as follows:
       <simplelist> 
        <member><literal>PDO::ATTR_AUTOCOMMIT</literal></member>
        <member><literal>PDO::ATTR_CASE</literal></member>
        <member><literal>PDO::ATTR_CLIENT_VERSION</literal></member>
        <member><literal>PDO::ATTR_CONNECTION_STATUS</literal></member>
        <member><literal>PDO::ATTR_DRIVER_NAME</literal></member>
        <member><literal>PDO::ATTR_ERRMODE</literal></member>
        <member><literal>PDO::ATTR_ORACLE_NULLS</literal></member>
        <member><literal>PDO::ATTR_PERSISTENT</literal></member>
        <member><literal>PDO::ATTR_PREFETCH</literal></member>
        <member><literal>PDO::ATTR_SERVER_INFO</literal></member>
        <member><literal>PDO::ATTR_SERVER_VERSION</literal></member>
        <member><literal>PDO::ATTR_TIMEOUT</literal></member>
       </simplelist> 
      </para>
      <simpara>
       Some drivers may make use of additional driver specific attributes.
       Note that driver specific attributes <emphasis>must not</emphasis> be used
       with other drivers.
      </simpara>
     </listitem>
     </varlistentry>
   </variablelist>
  </para>
 </refsect1>

 <refsect1 role="returnvalues">
  &reftitle.returnvalues;
  <para>
   A successful call returns the value of the requested PDO attribute.
   An unsuccessful call returns <literal>null</literal>.
  </para>
 </refsect1>

 <refsect1 role="examples">
  &reftitle.examples;
  <para>
   <example>
    <title>Retrieving database connection attributes</title>
    <programlisting role="php">
<![CDATA[
<?php
$conn = new PDO('odbc:sample', 'db2inst1', 'ibmdb2');
$attributes = array(
    "AUTOCOMMIT", "ERRMODE", "CASE", "CLIENT_VERSION", "CONNECTION_STATUS",
    "ORACLE_NULLS", "PERSISTENT", "PREFETCH", "SERVER_INFO", "SERVER_VERSION",
    "TIMEOUT"
);

foreach ($attributes as $val) {
    echo "PDO::ATTR_$val: ";
    echo $conn->getAttribute(constant("PDO::ATTR_$val")) . "\n";
}
?>
]]>
    </programlisting>
    <!--
    &example.outputs;
    <screen>
<![CDATA[
Use the PEAR Coding Standards
]]>
    </screen>
    -->
   </example>
  </para>
 </refsect1>

 <refsect1 role="seealso">
  &reftitle.seealso;
  <para>
   <simplelist>
    <member><methodname>PDO::setAttribute</methodname></member>
    <member><methodname>PDOStatement::getAttribute</methodname></member>
    <member><methodname>PDOStatement::setAttribute</methodname></member>
   </simplelist>
  </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:"~/.phpdoc/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
-->
