PDOStatement::errorInfo

Microsoft Drivers for PHP for SQL Server

Collapse image Expand Image Copy image CopyHover image

Retrieves extended error information of the most recent operation on the statement handle.

Syntax

array PDOStatement::errorInfo();

Return Value

An array of error information about the most recent operation on the statement handle. The array consists of the following fields:

  • The SQLSTATE error code

  • The driver-specific error code

  • The driver-specific error message

If there is no error, or if the SQLSTATE is not set, the driver-specific fields will be NULL.

Remarks

Support for PDO was added in version 2.0 of the Microsoft Drivers for PHP for SQL Server.

Example

In this example, the SQL statement has an error, which is then reported.

  Copy imageCopy Code
<?php
$conn = new PDO( "sqlsrv:server=(local) ; Database = AdventureWorks", "", "");
$stmt = $conn->prepare('SELECT * FROM Person.Addressx');

$stmt->execute();
print_r ($stmt->errorInfo());
?>

See Also

Reference

Other Resources

PDO