====== connect ====== ~~NOTOC~~ == See Also == [[v5:database:connection_matrix|The Connection Matrix]] == Syntax == bool 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. Since ADOdb 5.21,0, some database drivers support the use of [[v5:reference:connection:setconnectionparameter|setConnectionParameter()]], which should be called before connect() to pass extra, database-specific parameters to the connect statement. 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 [[v5:database:connection_matrix|Connection Matrix]] for assistance. If the connection is made, $db becomes a database connection object that can be used until the script ends. === Return value === The method returns //true// if the connection was successfully established, //false// otherwise. This should be checked before continuing with code execution. 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');