API Platform Conference 2026 - Lille (France) & Online

PDOStatement::setAttribute

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

PDOStatement::setAttribute Set a statement attribute

Description

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

Sets an attribute on the statement. Currently, no generic attributes are set but only driver specific:

  • PDO::ATTR_CURSOR_NAME (Firebird and ODBC specific): Set the name of the cursor for UPDATE ... WHERE CURRENT OF.

Note that driver specific attributes must not be used with other drivers.

Parameters

attribute

The attribute to modify.

value

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

Return Values

Returns true on success or false on failure.

Errors/Exceptions

As of PHP 8.5.0, when using the Firebird driver, a ValueError is thrown if the cursor name set via PDO::ATTR_CURSOR_NAME is too long.

Changelog

Version Description
8.5.0 When using the Firebird driver, a ValueError is now thrown if the cursor name set via PDO::ATTR_CURSOR_NAME is too long.

See Also

add a note

User Contributed Notes

There are no user contributed notes for this page.
To Top