PDO::setAttribute
PDO::setAttribute — Set attribute (PHP 5 >= 5.1.0, PECL pdo >= 0.1.0)
Description
Syntax
bool PDO::setAttribute ( int $attribute , mixed $value )
Sets an attribute on the database handle. Some general attributes are listed below; some drivers may use additional driver-specific attributes.
-
PDO::ATTR_CASE : Force column names to a specific case.
-
PDO::CASE_LOWER : Force column names to lower case.
-
PDO::CASE_NATURAL : Leave column names as returned by the database driver.
-
PDO::CASE_UPPER : Force column names to upper case.
-
PDO::ATTR_ERRMODE : Error reporting.
-
PDO::ERRMODE_SILENT : Just set error codes.
-
PDO::ERRMODE_WARNING : Raise E_WARNING errors.
-
PDO::ERRMODE_EXCEPTION : Throw 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 : Convert empty string to NULL.
-
PDO::NULL_TO_STRING : Convert NULL to an empty string.
-
PDO::ATTR_STRINGIFY_FETCHES : Convert numeric values to strings when fetching. Requires bool.
-
PDO::ATTR_STATEMENT_CLASS : Set user-supplied 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, which means there may be differences between drivers. For example, SQLite will wait this long before giving up on obtaining a writable lock, but other drivers may interpret this as a connection or read timeout. Requires int.
-
PDO::ATTR_AUTOCOMMIT (available in OCI, Firebird, and MySQL): Whether to autocommit every individual statement.
-
PDO::ATTR_EMULATE_PREPARES Enable or disable emulation of prepared statements. Some drivers do not support or have limited support for native prepared statements. Use this setting to force PDO to emulate prepared statements (if true), or to try to use native prepared statements (if false). If the driver cannot successfully prepare the current query, it will always revert to emulating the prepared statement. Requires bool.
-
PDO::MYSQL_ATTR_USE_BUFFERED_QUERY (available in MySQL): Use buffered queries.
-
PDO::ATTR_DEFAULT_FETCH_MODE : Set the default fetch mode. Description of modes can be found in the PDOStatement::fetch() documentation.
Return Value
Returns TRUE on success or FALSE on failure.