La clase PDOException

(PHP 5 >= 5.1.0, PHP 7, PHP 8)

Introducción

Representa un error emitido por PDO. No debe lanzarse una excepción PDOException desde el propio código. Ver el capítulo sobre las excepciones para obtener más información sobre las excepciones en PHP.

Sinopsis de la Clase

class PDOException extends RuntimeException {
/* Propiedades */
protected int|string $code;
public ?array $errorInfo = null;
/* Propiedades heredadas */
protected string $message = "";
private string $string = "";
protected string $file = "";
protected int $line;
private array $trace = [];
private ?Throwable $previous = null;
/* Métodos heredados */
public Exception::__construct(string $message = "", int $code = 0, ?Throwable $previous = null)
final public Exception::getCode(): int
final public Exception::getFile(): string
final public Exception::getLine(): int
final public Exception::getTrace(): array
}

Propiedades

errorInfo

Corresponde a PDO::errorInfo() o PDOStatement::errorInfo()

code

Código de error SQLSTATE. Utilice el método Exception::getCode() para acceder a él.