php adodb连接不同数据库

CODE:
<?php
include("adodb/adodb.inc.php"); //包含adodb类库文件
$conn = NewADOConnection('postgres');
$conn->Connect('localhost', 'root', 'pass', 'mydb'); //连接PostgreSQL数据库
?>

[复制此代码]CODE:
<?php
include("adodb/adodb.inc.php"); //包含adodb类库文件
$conn = NewADOConnection('mysql://root:1981427@localhost/test'); //连接MySQL数据库
?>

[复制此代码]CODE:
<?php
include("adodb/adodb.inc.php"); //包含adodb类库文件
$conn = NewADOConnection('mysql');
$conn->Connect('localhost', 'root', '1981427', 'test'); //连接MySQL数据库
?>

[复制此代码]CODE:
<?php
include("adodb/adodb.inc.php"); //包含adodb类库文件
$conn = NewADOConnection('mysql://root:1981427@localhost/test'); //连接数据库
?>

[复制此代码]CODE:
<?php
include("adodb/adodb.inc.php"); //包含adodb类库文件
$conn = NewADOConnection(' postgres ');
$conn->Connect('host=localhost port=5432 dbname=mydb'); //连接PostgreSQL数据库
?>

[复制此代码]CODE:
<?php
include("adodb/adodb.inc.php"); //包含adodb类库文件
$conn = NewADOConnection('postgres://root:pass@localhost/mydb'); //连接PostgreSQL数据库
?>

[复制此代码]CODE:
<?php
include("adodb/adodb.inc.php"); //包含adodb类库文件
$conn = NewADOConnection('access'); //连接Access数据库
$conn->Connect("Driver={Microsoft Access Driver (*.mdb)};Dbq=d:\\mydb.mdb;Uid=Admin;Pwd=;");
?>

[复制此代码]CODE:
<?php
include("adodb/adodb.inc.php"); //包含adodb类库文件
$conn=NewADOConnection('odbc_mssql'); //连接SQL Server数据库
$conn->Connect("Driver={SQL Server};Server=localhost;Database=mydb;",'username','password');
?>

[复制此代码]CODE:
<?php
include("adodb/adodb.inc.php"); //包含adodb类库文件
$conn=NewADOConnection('mssql'); //连接SQL Server数据库
$conn->Connect("localhost', 'username', 'password', 'mydb');
?>

[复制此代码]CODE:
<?php
include("adodb/adodb.inc.php"); //包含adodb类库文件
$conn=NewADOConnection('db2'); //连接DB2数据库
$conn->Connect("driver={IBM db2 odbc DRIVER};database=mydb;hostname=localhost;port=50000;
protocol=TCPIP;uid=root; pwd=pass");
?>

 

posted @ 2009-04-23 20:05  Develop  阅读(659)  评论(0编辑  收藏  举报