Linux and UNIX Man Pages

Linux & Unix Commands - Search Man Pages

pdo.setattribute(3) [php man page]

PDO.SETATTRIBUTE(3)							 1						       PDO.SETATTRIBUTE(3)

PDO
::setAttribute - Set an attribute SYNOPSIS
public bool PDO::setAttribute (int $attribute, mixed $value) DESCRIPTION
Sets an attribute on the database handle. Some of the available generic attributes are listed below; some drivers may make use of addi- tional driver specific attributes. o PDO::ATTR_CASE: Force column names to a specific case. o PDO::CASE_LOWER: Force column names to lower case. o PDO::CASE_NATURAL: Leave column names as returned by the database driver. o PDO::CASE_UPPER: Force column names to upper case. o PDO::ATTR_ERRMODE: Error reporting. o PDO::ERRMODE_SILENT: Just set error codes. o PDO::ERRMODE_WARNING: Raise E_WARNING. o PDO::ERRMODE_EXCEPTION: Throw exceptions. o PDO::ATTR_ORACLE_NULLS (available with all drivers, not just Oracle): Conversion of NULL and empty strings. o PDO::NULL_NATURAL: No conversion. o PDO::NULL_EMPTY_STRING: Empty string is converted to NULL. o PDO::NULL_TO_STRING: NULL is converted to an empty string. o PDO::ATTR_STRINGIFY_FETCHES: Convert numeric values to strings when fetching. Requires bool. o PDO::ATTR_STATEMENT_CLASS: Set user-supplied statement class derived from PDOStatement. Cannot be used with persistent PDO instances. Requires array(string classname, array(mixed constructor_args)). o PDO::ATTR_TIMEOUT: Specifies the timeout duration in seconds. 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 an writable lock, but other drivers may interpret this as a connect or a read timeout interval. Requires int. o PDO::ATTR_AUTOCOMMIT (available in OCI, Firebird and MySQL): Whether to autocommit every single statement. o PDO::ATTR_EMULATE_PREPARES 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 TRUE), or to try to use native prepared statements (if FALSE). It will always fall back to emulating the prepared statement if the driver cannot successfully prepare the current query. Requires bool. o PDO::MYSQL_ATTR_USE_BUFFERED_QUERY (available in MySQL): Use buffered queries. o PDO::ATTR_DEFAULT_FETCH_MODE: Set default fetch mode. Description of modes is available in PDOStatement.fetch(3) documentation. RETURN VALUES
Returns TRUE on success or FALSE on failure. PHP Documentation Group PDO.SETATTRIBUTE(3)

Check Out this Related Man Page

PDO.EXEC(3)								 1							       PDO.EXEC(3)

PDO
::exec - Execute an SQL statement and return the number of affected rows SYNOPSIS
public int PDO::exec (string $statement) DESCRIPTION
PDO.exec(3) executes an SQL statement in a single function call, returning the number of rows affected by the statement. PDO.exec(3) does not return results from a SELECT statement. For a SELECT statement that you only need to issue once during your program, consider issuing PDO.query(3). For a statement that you need to issue multiple times, prepare a PDOStatement object with PDO.prepare(3) and issue the statement with PDOStatement.execute(3). PARAMETERS
o $statement - The SQL statement to prepare and execute. Data inside the query should be properly escaped. RETURN VALUES
PDO.exec(3) returns the number of rows that were modified or deleted by the SQL statement you issued. If no rows were affected, PDO.exec(3) returns 0. Warning This function may return Boolean FALSE, but may also return a non-Boolean value which evaluates to FALSE. Please read the section on Booleans for more information. Use the === operator for testing the return value of this function. The following example incorrectly relies on the return value of PDO.exec(3), wherein a statement that affected 0 rows results in a call to die(3): <?php $db->exec() or die(print_r($db->errorInfo(), true)); ?> EXAMPLES
Example #1 Issuing a DELETE statement Count the number of rows deleted by a DELETE statement with no WHERE clause. <?php $dbh = new PDO('odbc:sample', 'db2inst1', 'ibmdb2'); /* Delete all rows from the FRUIT table */ $count = $dbh->exec("DELETE FROM fruit WHERE colour = 'red'"); /* Return number of rows that were deleted */ print("Deleted $count rows. "); ?> The above example will output: Deleted 1 rows. SEE ALSO
PDO.prepare(3), PDO.query(3), PDOStatement.execute(3). PHP Documentation Group PDO.EXEC(3)
Man Page