PDO::setAttribute — Set attributes (PHP 5 >= 5.1.0, PECL pdo >= 0.1.0)
bool PDO::setAttribute ( int $attribute , mixed $value )
Set database handle properties. Some of the common properties available are listed below; some drivers may use additional specific properties.
PDO::ATTR_CASE : Force column names to the specified case.
PDO::CASE_LOWER : Force column names to lowercase.
PDO::CASE_NATURAL : Preserve the column names returned by the database driver.
PDO::CASE_UPPER : Force column names to be uppercase.
PDO::ATTR_ERRMODE : error reporting.
PDO::ERRMODE_SILENT : Sets only the error code.
PDO::ERRMODE_WARNING : raises an E_WARNING error
PDO::ERRMODE_EXCEPTION : throws exceptions .
PDO::ATTR_ORACLE_NULLS (available in all drivers, not limited to Oracle): Convert 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 values to strings when extracting. Requires bool .
PDO::ATTR_STATEMENT_CLASS : Sets the user-supplied 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 number of seconds for timeout. Not all drivers support this option, which means there may be differences from driver to driver. For example, SQLite waits for this value before giving up acquiring a writable lock, but other drivers may interpret this value as a connection or read timeout interval. Requires int type.
PDO::ATTR_AUTOCOMMIT (available in OCI, Firebird and MySQL): Whether to automatically commit each individual statement.
PDO::ATTR_EMULATE_PREPARES enables or disables emulation of prepared statements. Some drivers have no or limited support for local preprocessing. Use this setting to force PDO to always emulate prepared statements (if TRUE
), or try to use native prepared statements (if FALSE
). If the driver cannot successfully prepare the current query, it will always fall back to simulating prepared statements. Requires bool type.
PDO::MYSQL_ATTR_USE_BUFFERED_QUERY (available in MySQL): Use buffered queries.
PDO::ATTR_DEFAULT_FETCH_MODE : Set the default fetch mode. A description of the mode can be found in the PDOStatement::fetch() documentation.
Returns TRUE on success, or FALSE on failure.