- skip to content

# Database Abstraction Layer

### User Tools

- Login

### Site Tools

- Recent changes
- Media Manager
- Sitemap

### Sidebar

##### Resources

- Reference Manual
- User Guide
- The Data Dictionary
- ADOdb-xmlschema
- ADOdb Active Record
- Performance Monitoring
- Date/Time Library
- Session Management Library
- Unsupported Addons
- Coding Standards

##### Supported Databases

- Access
- ADO
- CSV
- Firebird
- Frontbase
- IBM DB2
- Informix
- Interbase
- LDAP
- Microsoft SQL Server
- MySQL
- Netezza
- ODBC
- ODBTP
- Oracle
- PDO
- Postgresql
- SAP ADS
- SAP ASE
- SAP Maxdb
- SAP Sqlanywhere
- Sqlite
- Sybase
- Plain Text
- Visual Foxpro

##### Other

- Feature Comparison Matrix
- Connection Matrix
- Include File Guide

v5:reference:connection:connect

# connect

##### See Also

The Connection Matrix

##### Syntax

     mixed connect(
           optional string $parameter1 = '',
           optional string $parameter2 = '',
           optional string $parameter3 = '',
           optional string $parameter4 = '',
           optional bool $forceNewConnection=false
           )

## Description

The essential function `connect()` establishes a connection to a database using the provided parameters. The traditional description of the connection parameters is as follows:

Parameter 1 | Parameter 2 | Parameter 3 | Parameter 4
--- | --- | --- | ---
$hostName | $userId | $password | $database

However the actual values of the parameters for some databases are such that the actual requirements can be confusing. See the Connection Matrix for assistance.

If the connection is made, $db becomes a database connection object that can be used until the script ends. If the connection fails, the value is set to false.

To debug the connection, set the value `$db→debug = true;` before calling the `$db→connect` statement

## Usage

    /*
     *  Example using MySQL
    */
    include 'adodb.inc.php';
    /*
     * This is not a class below
     */
    $db = newADOConnection('mysqli');

    /*
     * Make a connection to a database on the local machine
     */
    $db->connect('','user','password'.'employees');

    /*
     *
     */

v5/reference/connection/connect.txt · Last modified: 2016/01/16 14:07 by mnewnham

### Page Tools

- Show pagesource
- Old revisions
- Backlinks
- Rename Page
- Back to top