Pdo Setattribute
# PDO::setAttribute
[PHP PDO Reference](#)
PDO::setAttribute β Sets a database handle attribute (PHP 5 >= 5.1.0, PECL pdo >= 0.1.0)
* * *
## Description
### Syntax
bool PDO::setAttribute ( int $attribute , mixed $value )
Sets a database handle attribute. Some commonly used attributes are listed below; some drivers may use additional, driver-specific attributes.
* _PDO::ATTR_CASE_: Forces column names to a specific case.
* _PDO::CASE_LOWER_: Forces column names to lower case.
* _PDO::CASE_NATURAL_: Preserves the column name as returned by the database driver.
* _PDO::CASE_UPPER_: Forces column names to upper case.
* _PDO::ATTR_ERRMODE_: Error reporting.
* _PDO::ERRMODE_SILENT_: Sets the error code only.
* _PDO::ERRMODE_WARNING_: Raises an _E_WARNING_ error.
* _PDO::ERRMODE_EXCEPTION_: Throws exceptions.
* _PDO::ATTR_ORACLE_NULLS_ (available in all drivers, not just Oracle): Conversion of NULL and empty strings.
* _PDO::NULL_NATURAL_: No conversion.
* _PDO::NULL_EMPTY_STRING_: Converts empty strings to **`NULL`**.
* _PDO::NULL_TO_STRING_: Converts NULL to an empty string.
* _PDO::ATTR_STRINGIFY_FETCHES_: Converts numeric values to strings when fetching. Requires _bool_.
* _PDO::ATTR_STATEMENT_CLASS_: Sets the user-provided statement class derived from PDOStatement. Cannot be used with persistent PDO instances. Requires _array(string class name, array(mixed constructor arguments))_.
* _PDO::ATTR_TIMEOUT_: Specifies the timeout duration in seconds. Not all drivers support this option, meaning there may be differences between drivers. For example, SQLite will abandon acquiring a writable lock after waiting for this value, but other drivers may interpret this value as a connection or read timeout interval. Requires _int_.
* _PDO::ATTR_AUTOCOMMIT_ (available in OCI, Firebird, and MySQL): Whether to autocommit each individual statement.
* _PDO::ATTR_EMULATE_PREPARES_: Enables or disables emulation of prepared statements. Some drivers do not support or have limited support for native prepared statements. Using this setting forces PDO to always emulate prepared statements (if set to **`TRUE`**), or to try to use native prepared statements (if set to **`FALSE`**). If the driver cannot successfully prepare the current query, it will always fall back to emulating prepared statements. Requires _bool_.
* _PDO::MYSQL_ATTR_USE_BUFFERED_QUERY_ (available in MySQL): Uses buffered queries.
* _PDO::ATTR_DEFAULT_FETCH_MODE_: Sets the default fetch mode. Information on modes can be found in the _PDOStatement::fetch()_ documentation.
* * *
## Return Value
Returns TRUE on success or FALSE on failure.
YouTip