Configuration and use of adodb

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

========================================================== =
Php100: 80: All-purpose Engine class of adodb php Database

Introduction and features of the adodb php Database
ADODB is a compatible interface for various database applications (APIS. MySQL, PostgreSQL, Interbase, Firebird, Informix, Oracle, ms SQL 7, Foxpro, Access, ADO, Sybase, FrontBase, DB2

ADODB standardizes the connection and use of various databases in PHP
ADODB helps us provide development efficiency and quick conversion of various databases in PHP
ADODB is relatively simple to use
The writing requirements of ADODB are strict and case sensitive.
Many built-in functions of ADODB

How to configure and use ADODB PHP
Download the ADODB For PHP class library compressed package
Decompress the package to any folder in the website directory.
Introduce the ADODB configuration file
Configure the required database connection
Use built-in methods to operate connected databases

Connect to MySql:

<? Php
Include_once ("adodb5/adodb. inc. php"); // contains the adodb class library file
$ Db = NewADOConnection ('mysql ');
$ Db-> Connect ('localhost', 'root', '123', 'test') or die ("df"); // Connect to the MySQL database
?>


Connection Access:

<? Php
Include_once ("adodb/adodb. inc. php"); // contains the adodb class library file
$ Conn = NewADOConnection ('access'); // connect to the access Database
$ Conn-> Connect ("test. mb") or die ("cuowu ");
?>

Connect to DB2:

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

Connect to PostgreSQL:

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

*******
Fast query using ADODB PHP
Include_once ("adodb5/adodb. inc. php ");

$ Db = & NewADOConnection ('mysql ');
$ Db-> Connect ("localhost", "root", "", "db") or die ("error ");
$ Db-> Execute ("set names 'gbk '");

$ Q = $ db-> Execute ("select * from up_admin_user ");

While ($ row = $ q-> FetchRow ()){
Print_r ($ row );
}
*************
Intelligent insertion using ADODB PHP

Include_once ("adodb5/adodb. inc. php ");

$ Db = & NewADOConnection ('mysql ');
$ Db-> Connect ("localhost", "root", "", "db") or die ("error ");
$ Db-> Execute ("set names 'gbk '");

$ Arr = array ('m _ id' => '2', 'Password' => '000000', '000000' => '000000 ');
$ Db-> AutoExecute ("up_admin_user", $ arr, "INSERT ");
************
Instance:
Query:
<? Php
Include_once ("adodb5/adodb. inc. php"); // contains the adodb class library file
$ Db = NewADOConnection ('mysql ');
$ Db-> Connect ('localhost', 'root', '', 'Think _ zw') or die (" error "); // Connect to the MySQL database
$ Db-> Execute ("set names 'gbk '");
$ Query = $ db-> Execute ("select * from think_zw ");
While ($ row = $ query-> FetchRow ()){
Print_r ($ row );
}
?>

Insert: when inserted, it automatically filters out unused arrays. Exclude unused arrays.
Fields can be inserted with different values.

<? Php
Include_once ("adodb5/adodb. inc. php"); // contains the adodb class library file
$ Db = NewADOConnection ('mysql ');
$ Db-> Connect ('localhost', 'root', '', 'Think _ zw') or die (" error "); // Connect to the MySQL database
$ Db-> Execute ("set names 'gbk '");
$ Arr = array ("id" => "",
"Name" => "Xiaojun ",
"Details" => "Xiaojun loves to watch beautiful women"); // do not write double quotation marks as single quotes
$ Db-> AutoExecute ("think_zw", $ arr, "INSERT ");
$ Query = $ db-> Execute ("select * from think_zw ");
While ($ row = $ query-> FetchRow ()){
Echo $ row [name]. "<br> ";
}
?>
====================================
Php100: 81: php adodb address connection

1. php adodb address connection to the database
2. Obtain database content using php adodb objects
3. php adodb html code display content
4. php adodb Enables automatic content Paging

Php adodb address connection to the database:
Include_once ("adodb5/adodb. inc. php ");

/* $ Db = NewADOConnection ('mysql: // root: @ localhost/upload ');
$ SQL = "SELECT * FROM 'pic '";
$ Db-> SetFetchMode (ADODB_FETCH_ASSOC); // The difference between ADODB_FETCH_NUM and fetch_array is similar.
// Mysql_fetch_array ()
$ Sr1 = $ db-> Execute ($ SQL );
Print_r ($ sr1-> fields );
*/
**********************
Php adodb object method for Retrieving Database content
$ Db = NewADOConnection ('mysql ');
$ Db-> PConnect ("localhost", "root", "", "upload ");
$ SQL = "SELECT * FROM 'pic '";
$ Rs2 = $ db-> Execute ($ SQL );
While ($ row = $ rs2-> FetchNextObject ()){
Echo $ row-> NAME;
}
*/
*******
Php adodb html code display content
/*
Include_once ("adodb5/tohtml. inc. php ");
$ Db = NewADOConnection ('mysql ');
$ Db-> Connect ("localhost", "root", "", "upload ");
$ SQL = "SELECT * FROM 'pic '";
$ Rs2 = $ db-> Execute ($ SQL );
Echo rs2html ($ rs2 );
*/
**************
Php adodb implements automatic content Paging
Include_once ("adodb5/adodb-pager.inc.php ");
Session_start ();
$ Db = NewADOConnection ('mysql ');
$ Db-> Connect ("localhost", "root", "", "upload ");
$ Db-> Execute ("set names 'gbk '");

$ SQL = "SELECT * FROM 'pic '";
$ Pager = new ADODB_Pager ($ db, $ SQL );
$ Pager-> Render (2 );

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.