PHP 8.5.0 Alpha 1 available for testing

Voting

: max(six, one)?
(Example: nine)

The Note You're Voting On

radu.potop at wooptoo.com
11 years ago
Since PDOException returns the error code as a string, you need a constructor like the one below if you wish to rethrow the PDOException as a custom exception.
This constructor does not call the parent::__construct which will enforce the int type on the error code, but set the message and code as properties directly on the custom exception object.

<?php

class CustomException extends PDOException {

/**
* Override constructor and set message and code properties.
* Workaround PHP BUGS #51742, #39615
*/
public function __construct($message=null, $code=null) {
$this->message = $message;
$this->code = $code;
}

}

<< Back to user notes page

To Top