Data Source Name (DSN) Support
Since ADOdb 4.51, you can connect to a database by passing a dsn to NewADOConnection (or ADONewConnection, which is
the same function). The dsn format is:
NewADOConnection() calls Connect() or PConnect() internally for you. If the connection fails, false is returned.
# non-persistent connection
$dsn = 'mysql://root:pwd@localhost/mydb';
$db = NewADOConnection($dsn);
if (!$db) die("Connection failed");
# no need to call connect/pconnect!
$arr = $db->GetArray("select * from table");
# persistent connection
$dsn2 = 'mysql://root:pwd@localhost/mydb?persist';
If you have special characters such as /:? in your dsn, then you need to rawurlencode them first:
$pwd = rawurlencode($pwd);
$dsn = "mysql://root:$pwd@localhost/mydb";
$dsn2 = rawurlencode("sybase_ase")."://user:pass@host/path?query";