PDO::setAttribute

(PHP 5 >= 5.1.0, PHP 7, PHP 8, PECL pdo >= 0.1.0)

PDO::setAttribute Set an attribute

Beschreibung

public PDO::setAttribute(int $attribute, mixed $value): bool

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_CASE

Force column names to a specific case. Can take one of the following values:

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 mode of PDO. Can take one of the following values:

PDO::ERRMODE_SILENT
Only sets error codes.
PDO::ERRMODE_WARNING
Raises E_WARNING diagnostics.
PDO::ERRMODE_EXCEPTION
Throws PDOExceptions.
PDO::ATTR_ORACLE_NULLS

Hinweis: 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_NATURAL
No conversion takes place.
PDO::NULL_EMPTY_STRING
Empty strings get converted to null.
PDO::NULL_TO_STRING
null gets converted to an empty string.
PDO::ATTR_STRINGIFY_FETCHES

Whether to convert numeric values to strings when fetching. Takes a value of type bool: true to enable and false to disable.

PDO::ATTR_STATEMENT_CLASS

Set user-supplied statement class derived from PDOStatement. Requires array(string classname, array(mixed constructor_args)).

Achtung

Cannot be used with persistent PDO instances.

PDO::ATTR_TIMEOUT

Specifies the timeout duration in seconds. Takes a value of type int.

Hinweis:

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_AUTOCOMMIT

Hinweis: 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_PREPARES

Hinweis: 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_QUERY

Hinweis: 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, false.

PDO::ATTR_DEFAULT_FETCH_MODE

Set the default fetch mode. A description of the modes and how to use them is available in the PDOStatement::fetch() documentation.

Parameter-Liste

attribute

The attribute to modify.

value

The value to set the attribute, might require a specific type depending on the attribute.

Rückgabewerte

Gibt bei Erfolg true zurück. Bei einem Fehler wird false zurückgegeben.

Siehe auch

Hier Kannst Du einen Kommentar verfassen


Bitte gib mindestens 10 Zeichen ein.
Wird geladen... Bitte warte.
* Pflichtangabe
Es sind noch keine Kommentare vorhanden.

Total Commander 11.00 (final) ist verfügbar!

Total Commander, ein beliebter Datei-Manager, hat kürzlich seine neueste Version, 11.00, veröffentlicht. Mit einer Vielzahl von neuen Funktionen und Korrekturen bietet diese Version den Benutzern ein verbessertes und optimiertes Erlebnis. ...

admin

Autor : admin
Kategorie: Software-Updates

Welche Technologien sollte ein PHP Programmierer beherrschen?

In der heutigen digitalen Welt ist die Rolle eines PHP Programmierers von großer Bedeutung. ...

admin

Autor : admin
Kategorie: Dies und Das

PHPUnit in der Version 10 erschienen

PHPUnit in der Version 10 erschienen

Das beliebte Testframeworks PHPUnit ist in der Version 10 erschienen und steht zum Download bereit ...

TheMax

Autor : TheMax
Kategorie: Software & Web-Development

Tutorial veröffentlichen

Tutorial veröffentlichen

Teile Dein Wissen mit anderen Entwicklern weltweit

Du bist Profi in deinem Bereich und möchtest dein Wissen teilen, dann melde dich jetzt an und teile es mit unserer PHP-Community

mehr erfahren

Tutorial veröffentlichen

Fragen zu PHP-Syntax

Dankeschön, deine Erklärungen lassen mich Beides schon einmal besser nachvollziehen. Bei 2) hatte ich mittlerweile etwas zu Namensräumen gefund ...

Geschrieben von BrotherJ am 12.09.2023 08:05:17
Forum: PHP Developer Forum
Datei Prüfung - Alles was zwischen /* und */ steht, einfärben.

In deinem Beispiel endet der Kommentar in Zeile 11. Die Zeilen 12 bis 16 sind nicht mehr eingeschlossen, denn Kommentarzeichen kann man so nicht v ...

Geschrieben von reddighamburg am 12.09.2023 00:57:14
Forum: PHP Developer Forum
Fragen zu PHP-Syntax

zu 1) Hier geht es um Typensicherheit. Das : Response sagt nichts anderes, als dass der zurückgegebene Wert in jedem Fall vom Typ Response ist. A ...

Geschrieben von reddighamburg am 12.09.2023 00:31:02
Forum: PHP Developer Forum
Google findet die Seite einfach nicht...

Hey, Es tut mir leid zu hören, dass du Schwierigkeiten mit der Indexierung deines Blogs hast. In solchen Fällen ist es wichtig, verschiedene As ...

Geschrieben von Nikolla am 08.09.2023 12:31:56
Forum: SEO - Suchmaschinen Tricks und Tipps