DB::connect()

DB::connect() -- connects to database

Synopsis

require_once 'DB.php';

object DB::connect (string $dsn [, boolean $options = false])

Description

Creates a new DB connection object and connect to the specified database

Parameter

string $dsn

Data Source Name. See the "DSN" section for further information.

boolean $options

If $options is TRUE the connection will be persistent (requires support by database driver). Default is FALSE. In future releases, this parameter will be an array and take different options depending on the database.

Return value

object - the created DB connection object, or a DB_Error object on error.

Throws

Table 20-1. Possible PEAR_Error values

Error codeError messageReasonSolution
DB_ERROR_NOT_FOUND null The database specific class was not found. Check the $dsn and make sure to have an complete installation of the DB-package and that you database is supported by DB.

Note

This function should be called statically

See

DB::disconnect() , Tutorial - Connect()