YouTip LogoYouTip

Pdo Construct

# PDO::__construct [![Image 3: PHP PDO Reference](#)PHP PDO Reference](#) PDO::__construct β€” Creates 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 for the DSN string. For some PDO drivers, this parameter is optional. * **password**: The password for 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 PDOException. * * * ## Example ### Creating a PDO instance by invoking the driver getMessage();}?> * * PHP PDO Reference](#)
← Pdo ErrorcodePdo Commit β†’