Private archive copy · Unofficial site · Content copyright belongs to Runoob Tutorial and the original authors · View Original

PDO::__construct

PDO::__construct

PHP PDO Reference ManualPHP PDO Reference Manual

PDO::__construct - Create a PDO instance representing a database connection (PHP 5 >= 5.1.0, PECL pdo >= 0.1.0)


Description

Syntax



PDO::__construct ( string $dsn [, string $username [, string $password [, array $driver_options ]]] )

Creates a PDO instance representing a connection to the requested database.

Parameter Description


Return Value

Returns a PDO object on success.


Errors/Exceptions

If the attempt to connect to the requested database fails, PDO::__construct() throws a PDO exception (PDOException).


Example

Create a PDO instance by calling the driver



getMessage();

}



?>


PHP PDO Reference ManualPHP PDO Reference Manual