<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> <html> <head> <meta http-equiv="content-type" content="text/html; charset=UTF-8"> <title>Set an attribute</title> </head> <body><div class="manualnavbar" style="text-align: center;"> <div class="prev" style="text-align: left; float: left;"><a href="pdo.rollback.html">PDO::rollBack</a></div> <div class="next" style="text-align: right; float: right;"><a href="class.pdostatement.html">PDOStatement</a></div> <div class="up"><a href="class.pdo.html">PDO</a></div> <div class="home"><a href="index.html">PHP Manual</a></div> </div><hr /><div id="pdo.setattribute" class="refentry"> <div class="refnamediv"> <h1 class="refname">PDO::setAttribute</h1> <p class="verinfo">(PHP 5 >= 5.1.0, PECL pdo >= 0.1.0)</p><p class="refpurpose"><span class="refname">PDO::setAttribute</span> — <span class="dc-title"> Set an attribute </span></p> </div> <div class="refsect1 description" id="refsect1-pdo.setattribute-description"> <h3 class="title">Description</h3> <div class="methodsynopsis dc-description"> <span class="modifier">public</span> <span class="type">bool</span> <span class="methodname"><strong>PDO::setAttribute</strong></span> ( <span class="methodparam"><span class="type">int</span> <code class="parameter">$attribute</code></span> , <span class="methodparam"><span class="type"><a href="language.pseudo-types.html#language.types.mixed" class="type mixed">mixed</a></span> <code class="parameter">$value</code></span> )</div> <p class="para rdfs-comment"> Sets an attribute on the database handle. Some of the available generic attributes are listed below; some drivers may make use of additional driver specific attributes. <ul class="itemizedlist"> <li class="listitem"><p class="para"> <em>PDO::ATTR_CASE</em>: Force column names to a specific case. <ul class="itemizedlist"> <li class="listitem"><p class="para"> <em>PDO::CASE_LOWER</em>: Force column names to lower case. </p></li> <li class="listitem"><p class="para"> <em>PDO::CASE_NATURAL</em>: Leave column names as returned by the database driver. </p></li> <li class="listitem"><p class="para"> <em>PDO::CASE_UPPER</em>: Force column names to upper case. </p></li> </ul> </p></li> <li class="listitem"><p class="para"><em>PDO::ATTR_ERRMODE</em>: Error reporting. <ul class="itemizedlist"> <li class="listitem"><p class="para"><em>PDO::ERRMODE_SILENT</em>: Just set error codes.</p></li> <li class="listitem"><p class="para"><em>PDO::ERRMODE_WARNING</em>: Raise <a href="" class="link">E_WARNING</a>.</p></li> <li class="listitem"><p class="para"><em>PDO::ERRMODE_EXCEPTION</em>: Throw <a href="class.pdoexception.html" class="link">exceptions</a>.</p></li> </ul> </p></li> <li class="listitem"><p class="para"><em>PDO::ATTR_ORACLE_NULLS</em> (available with all drivers, not just Oracle): Conversion of NULL and empty strings. <ul class="itemizedlist"> <li class="listitem"><p class="para"><em>PDO::NULL_NATURAL</em>: No conversion.</p></li> <li class="listitem"><p class="para"><em>PDO::NULL_EMPTY_STRING</em>: Empty string is converted to <strong><code>NULL</code></strong>.</p></li> <li class="listitem"><p class="para"><em>PDO::NULL_TO_STRING</em>: NULL is converted to an empty string.</p></li> </ul> </p></li> <li class="listitem"><p class="para"><em>PDO::ATTR_STRINGIFY_FETCHES</em>: Convert numeric values to strings when fetching. Requires <span class="type"><a href="language.types.boolean.html" class="type bool">bool</a></span>. </p></li> <li class="listitem"><p class="para"><em>PDO::ATTR_STATEMENT_CLASS</em>: Set user-supplied statement class derived from PDOStatement. Cannot be used with persistent PDO instances. Requires <em>array(string classname, array(mixed constructor_args))</em>. </p></li> <li class="listitem"><p class="para"><em>PDO::ATTR_TIMEOUT</em>: Specifies the timeout duration in seconds. Not all drivers support this option, and it's meaning may differ from driver to driver. For example, sqlite will wait for up to this time value before giving up on obtaining an writable lock, but other drivers may interpret this as a connect or a read timeout interval. Requires <span class="type"><a href="language.types.integer.html" class="type int">int</a></span>. </p></li> <li class="listitem"><p class="para"><em>PDO::ATTR_AUTOCOMMIT</em> (available in OCI, Firebird and MySQL): Whether to autocommit every single statement. </p></li> <li class="listitem"><p class="para"><em>PDO::ATTR_EMULATE_PREPARES</em> Enables or disables emulation of prepared statements. Some drivers do not support native prepared statements or have limited support for them. Use this setting to force PDO to either always emulate prepared statements (if <strong><code>TRUE</code></strong>), or to try to use native prepared statements (if <strong><code>FALSE</code></strong>). It will always fall back to emulating the prepared statement if the driver cannot successfully prepare the current query. Requires <span class="type"><a href="language.types.boolean.html" class="type bool">bool</a></span>. </p></li> <li class="listitem"><p class="para"><em>PDO::MYSQL_ATTR_USE_BUFFERED_QUERY</em> (available in MySQL): Use buffered queries. </p></li> <li class="listitem"><p class="para"><em>PDO::ATTR_DEFAULT_FETCH_MODE</em>: Set default fetch mode. Description of modes is available in <span class="function"><a href="pdostatement.fetch.html" class="function">PDOStatement::fetch()</a></span> documentation. </p></li> </ul> </p> </div> <div class="refsect1 returnvalues" id="refsect1-pdo.setattribute-returnvalues"> <h3 class="title">Return Values</h3> <p class="para"> Returns <strong><code>TRUE</code></strong> on success or <strong><code>FALSE</code></strong> on failure. </p> </div> </div><hr /><div class="manualnavbar" style="text-align: center;"> <div class="prev" style="text-align: left; float: left;"><a href="pdo.rollback.html">PDO::rollBack</a></div> <div class="next" style="text-align: right; float: right;"><a href="class.pdostatement.html">PDOStatement</a></div> <div class="up"><a href="class.pdo.html">PDO</a></div> <div class="home"><a href="index.html">PHP Manual</a></div> </div></body></html>