PDO::getAttribute — Retrieve attributes of a database connection (PHP 5 >= 5.1.0, PECL pdo >= 0.1.0)
mixed PDO::getAttribute ( int $attribute )
This function (method) returns the property value of a database connection. To retrieve PDOStatement attributes, see PDOStatement::getAttribute().
Note that some databases/drivers may not support all database connection properties.
attribute : One of PDO::ATTR_* constants. The following are constants that apply to database connections:
PDO::ATTR_AUTOCOMMIT
PDO::ATTR_CASE
PDO::ATTR_CLIENT_VERSION
PDO::ATTR_CONNECTION_STATUS
PDO::ATTR_DRIVER_NAME
PDO::ATTR_ERRMODE
PDO::ATTR_ORACLE_NULLS
PDO::ATTR_PERSISTENT
PDO::ATTR_PREFETCH
PDO::ATTR_SERVER_INFO
PDO::ATTR_SERVER_VERSION
PDO::ATTR_TIMEOUT
A successful call returns the requested PDO attribute value. Returns null if unsuccessful.
<?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";}?>