Before interacting with data, a connection needs to be first established to the database. The parameters required to connect to the database are the same as when using a direct PHP connection. For detailed information about connections, see connect().
In addition to ensuring the correct database connection driver is available in the PHP configuration, a matching ADOdb driver must be selected. As a general rule, the Native Mode drivers (e.g. mysqli, postgres9, oci8) are faster and have more features than generic drivers (e.g. odbc_mssql2012, pdo_access), so if you have the choice, you should select one of those.
ADOdb versions 5 and lower do not support class autoloading, so the base library must be included in all the programs that use its features. Only the base class need be included, if required extended features are , they will be automatically included. See also the Include File Guide.
include 'adodb_dir/adodb.inc.php'; /* * This is the driver you have selected to use */ $driver = 'mysqli'; $db = newAdoConnection($driver); /* * These are the parameters required to connect to the database see connect() */ $db->connect($parameters);
$db object is used for all ADOdb activity. If the connection fails, the connect statement returns false and an error is logged.
In order to test if a connection has been established, the command
can be executed.
ADOdb provides a debugging mode, set simply by setting the parameter
$db->debug = true;
The earliest that it can be set is after the creation of the
$db connection object. It can also be switched on or off as required. For more information, see Debugging Guide.