Phpadodb connects to different databases

Source: Internet
Author: User
Tags db2 odbc driver ibm db2 ibm db2 odbc driver
Implementation code for connecting phpadodb to different databases. The code is as follows:


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
?>



The code is as follows:


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



The code is as follows:


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
?>



The code is as follows:


Include ("adodb/adodb. inc. php"); // contains the adodb class library file
$ Conn = NewADOConnection ('MySQL: // root: 1981427 @ localhost/test'); // connect to the database
?>


The code is as follows:


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
?>


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
?>



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



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


The code is as follows:


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


The code is as follows:


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.