Examples of Connecting to Databases
MySQL and Most Other Database Drivers
MySQL connections are very straightforward, and the parameters are identical to mysql_connect: $conn = &ADONewConnection('mysql');  $conn->PConnect('localhost','userid','password','database'); # or dsn 
$dsn = 'mysql://user:pwd@localhost/mydb'; 
$conn = ADONewConnection($dsn);  # no need for Connect()

# or persistent dsn
$dsn = 'mysql://user:pwd@localhost/mydb?persist'; 
$conn = ADONewConnection($dsn);  # no need for PConnect()

# a more complex example:
$pwd = urlencode($pwd);
$flags =  MYSQL_CLIENT_COMPRESS;
$dsn = "mysql://user:$pwd@localhost/mydb?persist&clientflags=$flags";
$conn = ADONewConnection($dsn);  # no need for PConnect()
 
For most drivers, you can use the standard function: Connect($server, $user, $password, $database), or a DSN since ADOdb 4.51. Exceptions to this are listed below. 

解决方案 »

  1.   

    手册上的,你可以自已看看试试Oracle (oci8)
    With oci8, you can connect in multiple ways. Note that oci8 works fine with newer versions of the Oracle, eg. 9i and 10g.a. PHP and Oracle reside on the same machine, use default SID. $conn->Connect(false, 'scott', 'tiger');
    b. TNS Name defined in tnsnames.ora (or ONAMES or HOSTNAMES), eg. 'myTNS' $conn->PConnect(false, 'scott', 'tiger', 'myTNS');
    or  $conn->PConnect('myTNS', 'scott', 'tiger');
    c. Host Address and SID $conn->connectSID = true;
    $conn->Connect('192.168.0.1', 'scott', 'tiger', 'SID');
    d. Host Address and Service Name $conn->Connect('192.168.0.1', 'scott', 'tiger', 'servicename');
    e. Oracle connection string:  $cstr = "(DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=$host)(PORT=$port)) (CONNECT_DATA=(SID=$sid)))"; $conn->Connect($cstr, 'scott', 'tiger');
    f. ADOdb dsn:  $dsn = 'oci8://user:pwd@tnsname/?persist';  # persist is optional $conn = ADONewConnection($dsn);  # no need for Connect/PConnect $dsn = 'oci8://user:pwd@host/sid';  $conn = ADONewConnection($dsn); $dsn = 'oci8://user:pwd@/';   # oracle on local machine $conn = ADONewConnection($dsn);
    You can also set the charSet for Oracle 9.2 and later, supported since PHP 4.3.2, ADOdb 4.54:  $conn->charSet = 'we8iso8859p1'; $conn->Connect(...); # or $dsn = 'oci8://user:pwd@tnsname/?charset=WE8MSWIN1252'; $db = ADONewConnection($dsn);