PHP ADODB Connect different database _php base

Source: Internet
Author: User
Tags db2 db2 odbc driver ibm db2 ibm db2 odbc driver postgresql access database
Copy Code code as follows:

<?php
Include ("adodb/adodb.inc.php"); Contains ADODB class library files
$conn = newadoconnection (' Postgres ');
$conn->connect (' localhost ', ' root ', ' pass ', ' mydb '); Connecting to the PostgreSQL database
?>


Copy Code code as follows:

<?php
Include ("adodb/adodb.inc.php"); Contains ADODB class library files
$conn = newadoconnection (' mysql://root:1981427@localhost/test '); Connecting to the MySQL database
?>


Copy Code code as follows:

<?php
Include ("adodb/adodb.inc.php"); Contains ADODB class library files
$conn = newadoconnection (' mysql ');
$conn->connect (' localhost ', ' root ', ' 1981427 ', ' test '); Connecting to the MySQL database
?>


Copy Code code as follows:

<?php
Include ("adodb/adodb.inc.php"); Contains ADODB class library files
$conn = newadoconnection (' mysql://root:1981427@localhost/test '); Connecting to a database
?>

Copy Code code as follows:

<?php
Include ("adodb/adodb.inc.php"); Contains ADODB class library files
$conn = newadoconnection (' Postgres ');
$conn->connect (' host=localhost port=5432 dbname=mydb '); Connecting to the PostgreSQL database
?>

Copy Code code as follows:

<?php
Include ("adodb/adodb.inc.php"); Contains ADODB class library files
$conn = newadoconnection (' Postgres://root:pass@localhost/mydb '); Connecting to the PostgreSQL database
?>


Copy Code code as follows:

<?php
Include ("adodb/adodb.inc.php"); Contains ADODB class library files
$conn = newadoconnection (' access '); Connect to an Access database
$conn->connect ("Driver={microsoft Access Driver (*.mdb)};D Bq=d:\\mydb.mdb; Uid=admin; pwd=; ");
?>


Copy Code code as follows:

<?php
Include ("adodb/adodb.inc.php"); Contains ADODB class library files
$conn =newadoconnection (' Odbc_mssql '); Connecting to SQL Server databases
$conn->connect ("Driver={sql Server}"; Server=localhost;database=mydb; ", ' username ', ' password ');
?>

Copy Code code as follows:

<?php
Include ("adodb/adodb.inc.php"); Contains ADODB class library files
$conn =newadoconnection (' MSSQL '); Connecting to SQL Server databases
$conn->connect ("localhost", ' username ', ' password ', ' mydb ');
?>

Copy Code code as follows:

<?php
include ("adodb/adodb.inc.php");///Contains ADODB class library file
$conn = Newadoconnection (' DB2 '); Connect the DB2 database
$conn->connect ("DRIVER={IBM DB2 ODBC driver};d atabase=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.