(PHP 5 >= 5.1.0, PHP 7, PHP 8, PECL pdo >= 0.1.0)
PDO::setAttribute — Set an attribute
Sets an attribute on the database handle. Some available generic attributes are listed below; some drivers may make use of additional driver specific attributes. Note that driver specific attributes must not be used with other drivers.
PDO::ATTR_CASEForce column names to a specific case. Can take one of the following values:
PDO::CASE_LOWERPDO::CASE_NATURALPDO::CASE_UPPERPDO::ATTR_ERRMODEError reporting mode of PDO. Can take one of the following values:
PDO::ERRMODE_SILENTPDO::ERRMODE_WARNINGE_WARNING diagnostics.
PDO::ERRMODE_EXCEPTIONPDO::ATTR_ORACLE_NULLSNote: This attribute is available with all drivers, not just Oracle.
Determines if and how null and empty strings should be converted.
Can take one of the following values:
PDO::NULL_NATURALPDO::NULL_EMPTY_STRINGnull.
PDO::NULL_TO_STRINGnull gets converted to an empty string.
PDO::ATTR_STRINGIFY_FETCHES
Controls whether fetched values (except null) are converted to strings.
Takes a value of type bool: true to enable and false to
disable (default).
null values remain unchanged unless PDO::ATTR_ORACLE_NULLS
is set to PDO::NULL_TO_STRING.
PDO::ATTR_STATEMENT_CLASS
Set user-supplied statement class derived from PDOStatement.
Requires array(string classname, array(mixed constructor_args)).
Cannot be used with persistent PDO instances.
PDO::ATTR_TIMEOUTSpecifies the timeout duration in seconds. Takes a value of type int.
Note:
Not all drivers support this option, and its meaning may differ from driver to driver. For example, SQLite will wait for up to this time value before giving up on obtaining a writable lock, but other drivers may interpret this as a connection or a read timeout interval.
PDO::ATTR_AUTOCOMMITNote: Only available for the OCI, Firebird, and MySQL drivers.
Whether to autocommit every single statement.
Takes a value of type bool: true to enable and
false to disable. By default, true.
PDO::ATTR_EMULATE_PREPARESNote: Only available for the OCI, Firebird, and MySQL drivers.
Whether enable or disable emulation of prepared statements.
Some drivers do not support prepared statements natively or have
limited support for them.
If set to true PDO will always emulate prepared statements,
otherwise PDO will attempt to use native prepared statements.
In case the driver cannot successfully prepare the current query,
PDO will always fall back to emulating the prepared statement.
PDO::MYSQL_ATTR_USE_BUFFERED_QUERYNote: Only available for the MySQL driver.
Whether to use buffered queries.
Takes a value of type bool: true to enable and
false to disable. By default, true.
PDO::ATTR_DEFAULT_FETCH_MODESet the default fetch mode. A description of the modes and how to use them is available in the PDOStatement::fetch() documentation.
attributeThe attribute to modify.
value
The value to set the attribute,
might require a specific type depending on the attribute.