Php adodb connects to different databases

Source: Internet
Author: User
Tags db2 odbc driver ibm db2 ibm db2 odbc driver

CopyCode The Code is as follows: <? PHP
Include ("ADODB/ADODB. Inc. php"); // contains the ADODB class library file
$ Conn = newadoconnection ('Seconds s ');
$ Conn-> connect ('localhost', 'root', 'pass', 'mydb'); // connect to the PostgreSQL database
?> Copy code The Code is as follows: <? PHP
Include ("ADODB/ADODB. Inc. php"); // contains the ADODB class library file
$ Conn = newadoconnection ('mysql: // root: 1981427 @ localhost/test'); // connect to the MySQL database
?> Copy code The Code is as follows: <? PHP
Include ("ADODB/ADODB. Inc. php"); // contains the ADODB class library file
$ Conn = newadoconnection ('mysql ');
$ Conn-> connect ('localhost', 'root', '000000', 'test'); // connect to the MySQL database
?> Copy code The Code is as follows: <? PHP
Include ("ADODB/ADODB. Inc. php"); // contains the ADODB class library file
$ Conn = newadoconnection ('mysql: // root: 1981427 @ localhost/test'); // connect to the database
?>

Copy codeThe Code is as follows: <? PHP
Include ("ADODB/ADODB. Inc. php"); // contains the ADODB class library file
$ Conn = newadoconnection ('Seconds s ');
$ Conn-> connect ('host = localhost Port = 5432 dbname = mydb'); // connect to the PostgreSQL database
?>

copy the Code the code is as follows: include ("ADODB/ADODB. inc. PHP "); // contains the ADODB class library file
$ conn = newadoconnection ('s s: // root: Pass @ localhost/mydb '); // connect to the PostgreSQL database
?> copy Code the code is as follows: include ("ADODB/ADODB. inc. PHP "); // contains the ADODB class library file
$ conn = newadoconnection ('access '); // connect to the ACCESS database
$ Conn-> connect ("driver = {Microsoft Access Driver (*. MDB)}; DBQ = D: \ mydb. MDB; uid = admin; Pwd =; ");
?> copy Code the code is as follows: include ("ADODB/ADODB. inc. PHP "); // contains the ADODB class library file
$ conn = newadoconnection ('odbc _ mssql '); // connect to the SQL Server database
$ Conn-> connect ("driver = {SQL Server}; server = localhost; database = mydb;", 'username ', 'Password');
?>

Copy codeThe Code is as follows: <? PHP
Include ("ADODB/ADODB. Inc. php"); // contains the ADODB class library file
$ Conn = newadoconnection ('mssql'); // connect to the SQL Server database
$ Conn-> connect ("localhost", 'username', 'Password', 'mydb ');
?>

Copy codeThe Code is as follows: <? PHP
Include ("ADODB/ADODB. Inc. php"); // contains the ADODB class library file
$ Conn = newadoconnection ('db2 '); // connect to the DB2 database
$ Conn-> connect ("driver = {IBM DB2 ODBC driver}; database = mydb; hostname = localhost; Port = 50000;
Protocol = TCPIP; uid = root; Pwd = pass ");
?>

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.