Home  >  Article  >  Backend Development  >  php adodb connects to different databases_PHP tutorial

php adodb connects to different databases_PHP tutorial

WBOY
WBOYOriginal
2016-07-21 15:46:56811browse

Copy code The code is as follows:

include("adodb/adodb.inc.php"); /Contains adodb class library file
$conn = NewADOConnection('postgres');
$conn->Connect('localhost', 'root', 'pass', 'mydb'); //Connect to PostgreSQL Database
?>


Copy code The code is as follows:

< ?php
include("adodb/adodb.inc.php"); //Include adodb class library file
$conn = NewADOConnection('mysql://root:1981427@localhost/test'); // Connect to MySQL database
?>


Copy code The code is as follows:

include("adodb/adodb.inc.php"); //Include adodb class library file
$conn = NewADOConnection('mysql');
$conn->Connect( 'localhost', 'root', '1981427', 'test'); //Connect to MySQL database
?>


Copy Code The code is as follows:

include("adodb/adodb.inc.php"); //Include adodb class library file
$ conn = NewADOConnection('mysql://root:1981427@localhost/test'); //Connect to the database
?>

Copy code The code is as follows:

include("adodb/adodb.inc.php"); //Include adodb class library file
$conn = NewADOConnection(' postgres ');
$conn->Connect('host=localhost port=5432 dbname=mydb'); //Connect to PostgreSQL database
?>

Copy code The code is as follows:

include("adodb/adodb.inc.php"); /Contains adodb class library file
$conn = NewADOConnection('postgres://root:pass@localhost/mydb'); //Connect to PostgreSQL database
?>


Copy code The code is as follows:

include("adodb/adodb.inc.php") ; //Contains adodb class library file
$conn = NewADOConnection('access'); //Connect to Access database
$conn->Connect("Driver={Microsoft Access Driver (*.mdb)}; Dbq=d:\mydb.mdb;Uid=Admin;Pwd=;");
?>


Copy codeThe code is as follows:

include("adodb/adodb.inc.php"); //Include adodb class library file
$conn=NewADOConnection ('odbc_mssql'); //Connect to SQL Server database
$conn->Connect("Driver={SQL Server};Server=localhost;Database=mydb;",'username','password');
?>

Copy code The code is as follows:

include("adodb/adodb.inc.php"); //Include adodb class library file
$conn=NewADOConnection('mssql'); //Connect to SQL Server database
$conn->Connect(" localhost', 'username', 'password', 'mydb');
?>

Copy code The code is as follows :

include("adodb/adodb.inc.php"); //Include adodb class library file
$conn=NewADOConnection('db2'); //Connect to DB2 database
$conn->Connect("driver={IBM db2 odbc DRIVER};database=mydb;hostname=localhost;port=50000;
protocol=TCPIP;uid=root; pwd= pass");
?>

www.bkjia.comtruehttp: //www.bkjia.com/PHPjc/320053.htmlTechArticleCopy the code as follows: ?php include("adodb/adodb.inc.php"); //Include adodb Class library file $conn = NewADOConnection('postgres'); $conn-Connect('localhost', 'root', 'pass', 'mydb');...
Statement:
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