PHP: PDO->setAttribute() - Manual

downloads | documentation | faq | getting help | mailing lists | reporting bugs | php.net sites | links | conferences | my php.net

search for in the

PDOStatement->bindColumn() PDO->rollBack()

Last updated: Fri, 26 Jan 2007

view this page in

# PDO->setAttribute()

(no version information, might be only in CVS)

PDO->setAttribute() -- Set an attribute

## Описание

class PDO {
bool setAttribute ( int attribute, mixed value )
}

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.

- `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.

  - `PDO::ERRMODE_EXCEPTION`: Throw exceptions.

- `PDO::ATTR_ORACLE_NULLS` (available with all drivers, not just Oracle): Conversion of NULL and empty strings.

  - `PDO::NULL_NATURAL`: No conversion.

  - `PDO::NULL_EMPTY_STRING`: Empty string is converted to `NULL`.

  - `PDO::NULL_TO_STRING`: NULL is converted 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 classname, array(mixed constructor_args))`.

- `PDO::ATTR_AUTOCOMMIT` (available in OCI, Firebird and MySQL): Whether to autocommit every single statement.

- `PDO::MYSQL_ATTR_USE_BUFFERED_QUERY` (available in MySQL): Use buffered queries.

## Возвращаемые значения

Возвращает `TRUE` в случае успешного завершения или `FALSE` в случае возникновения ошибки.

add a note User Contributed Notes
PDO->setAttribute()
Tobi
20-Nov-2006 03:11
`Hint: setting the PDO::ATTR_ERRMODE attribute to PDO::ERRMODE_EXCEPTION
worked for me only with Mysql 4.x - I took me some time to figure this out ;-)`
m dot leuffen at gmx dot de
25-Jul-2006 06:44
`Hi,
if you are wondering about a size-bound (1 MB) on blob and text fields after upgrading to PHP5.1.4. You might try to increase this limit by using the setAttribute() method.
This will fail. Instead use the options array when instantiating the pdo:
$pdo = new PDO ("connection_settings", "user", "pass", array
(PDO::MYSQL_ATTR_MAX_BUFFER_SIZE=>1024*1024*50));
This should fix the problem and increase the limit to 50 MB.
Bye,
Matthias`
add a note
PDOStatement->bindColumn() PDO->rollBack()

Last updated: Fri, 26 Jan 2007
show source | credits | stats | sitemap | contact | advertising | mirror sites
Copyright © 2001-2007 The PHP Group
All rights reserved.
This mirror generously provided by: Yahoo! Inc.
Last updated: Sat Mar 10 10:36:09 2007 PST