Home > php教程 > php手册 > body text

php adodb连接不同数据库

WBOY
Release: 2016-06-13 12:24:04
Original
767 people have browsed it

复制代码 代码如下:


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



复制代码 代码如下:


include("adodb/adodb.inc.php"); //包含adodb类库文件
$conn = NewADOConnection('mysql://root:1981427@localhost/test'); //连接MySQL数据库
?>



复制代码 代码如下:


include("adodb/adodb.inc.php"); //包含adodb类库文件
$conn = NewADOConnection('mysql');
$conn->Connect('localhost', 'root', '1981427', 'test'); //连接MySQL数据库
?>



复制代码 代码如下:


include("adodb/adodb.inc.php"); //包含adodb类库文件
$conn = NewADOConnection('mysql://root:1981427@localhost/test'); //连接数据库
?>


复制代码 代码如下:


include("adodb/adodb.inc.php"); //包含adodb类库文件
$conn = NewADOConnection(' postgres ');
$conn->Connect('host=localhost port=5432 dbname=mydb'); //连接PostgreSQL数据库
?>


复制代码 代码如下:


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



复制代码 代码如下:


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



复制代码 代码如下:


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


复制代码 代码如下:


include("adodb/adodb.inc.php"); //包含adodb类库文件
$conn=NewADOConnection('mssql'); //连接SQL Server数据库
$conn->Connect("localhost', 'username', 'password', 'mydb');
?>


复制代码 代码如下:


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");
?>

source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Recommendations
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template