PDO::__construct
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
- dsn: The data source name, or DSN, contains the information required to connect to the database.
- username: The username in the DSN string. For some PDO drivers, this parameter is optional.
- **password**: The password in the DSN string. For some PDO drivers, this parameter is optional.
- **driver_options**: A key=>value array of driver-specific connection options.
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 Manual