更好地处理不支持属性的示例
<?php
$conn = new PDO( 'odbc:sample', 'db2inst1', 'ibmdb2' );
$conn->setAttribute( PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION );
$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: ";
try {
echo $conn->getAttribute( constant( "PDO::ATTR_$val" ) ) . "\n";
} catch ( PDOException $e ) {
echo $e->getMessage() . "\n";
}
}
?>