PDO::setAttribute
PDO::setAttribute - Set an 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 available general attributes are listed below; some drivers may use additional specific attributes.
-
PDO::ATTR_CASE: Forces column names to a specified case.
-
PDO::CASE_LOWER: Forces column names to lowercase.
-
PDO::CASE_NATURAL: Preserves the column names returned by the database driver.
-
PDO::CASE_UPPER: Forces column names to uppercase.
PDO::CASE_LOWER: Forces column names to lowercase.
-PDO::CASE_NATURAL: Preserves the column names returned by the database driver.
-PDO::CASE_UPPER: Forces column names to uppercase.
-
PDO::ATTR_ERRMODE: Error reporting.
-
PDO::ERRMODE_SILENT: Sets only the error code.
-
PDO::ERRMODE_WARNING: Raises E_WARNING Error
-
PDO::ERRMODE_EXCEPTION: Throws exceptions exception.
PDO::ERRMODE_SILENT: Sets only the error code.
-PDO::ERRMODE_WARNING: Raises E_WARNING Error
-PDO::ERRMODE_EXCEPTION: Throws exceptions exception.
-
PDO::ATTR_ORACLE_NULLS (available in all drivers, not just Oracle): Converts NULL and empty strings.
-
PDO::NULL_NATURAL: Does not convert.
-
PDO::NULL_EMPTY_STRING: Converts an empty string to
NULL. -
PDO::NULL_TO_STRING: Converts NULL to an empty string.
PDO::NULL_NATURAL: Does not convert.
-PDO::NULL_EMPTY_STRING: Converts an empty string 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 a user-provided statement class derived from PDOStatement. Cannot be used with persistent PDO instances. Requires array(string class name, array(mixed constructor parameters)).
-
PDO::ATTR_TIMEOUT: Specifies the timeout in seconds. Not all drivers support this option, which means there may be differences between drivers. For example, SQLite gives up acquiring a writable lock after waiting this amount of time, but other drivers may interpret this value as an interval for connection or read timeout. Requires an int type.
-
PDO::ATTR_AUTOCOMMIT (available in OCI, Firebird and MySQL): Whether to autocommit each individual statement.
-
PDO::ATTR_EMULATE_PREPARES Enables or disables the emulation of prepared statements. Some drivers do not support or only partially support native prepared statements. Use this setting to force PDO to always emulate prepared statements (if
TRUE), or to try using native prepared statements (ifFALSE). If the driver cannot successfully prepare the current query, it always falls back to emulating prepared statements. Requires bool type. -
PDO::MYSQL_ATTR_USE_BUFFERED_QUERY (available in MySQL): Use buffered queries.
-
PDO::ATTR_DEFAULT_FETCH_MODE: Sets the default fetch mode. Notes about the mode can be found in the PDOStatement::fetch() documentation.
Return Value
Returns TRUE on success, or FALSE on failure.
PHP PDO Reference Manual