Usage of PHP ADODB

Source: Internet
Author: User
ADODB is the abbreviation for Active data Objects data Base, which is an intermediate function component of a PHP Access database.

Although PHP is a powerful tool for building WEB systems, the functionality of PHP Access databases has not been standardized, and each database uses a different and incompatible application interface (API). In order to fill this shortcoming, there is only ADODB. Once the interface for accessing the database is standardized, it is possible to hide the differences of various databases, which can be very easy to convert to different databases.

Currently the latest version of ADODB is V5.16, which supports a wide variety of databases, such as: MySQL, PostgreSQL, Interbase, Informix, Oracle, MS SQL 7, Foxpro, Access, ADO, Sybase, DB2 and General ODBC (where PostgreSQL, Informix, Sybase's driver are contributed by the development of the free software community).

One of the greatest advantages of using ADODB is that regardless of the backend database, access to the database is consistent, and the development designer does not need to learn a different set of access methods for a particular set of databases, which greatly reduces the developer's knowledge burden, the knowledge of the past can continue to use, The program code does not have to change too much when transferring the database platform.

In fact, ADODB such a development concept, is not the first, DBI appears earlier than ADODB, it provides Perl access to the database, using a consistent API call interface. I believe that using Perl + DBI friends, and then use ADODB, there will be a sense of déjà vu.

In addition, ADODB for the use of the ASP, should not be unfamiliar, this kind of friend to ADODB should be very easy to accept.

Suppose the database name is a table named b//contains the ADODB class include_once ("adodb.inc.php");//type of link database----------------------link mode 1$db= Newadoconnection ("MySQL"); $db->connect ("localhost", "root", "my123", "a") or Die ("link Database error");//------------------ ------------------------Link Way 2//$db-//>newadoconnection ("mysql://root:my123@localhost/b")//Set character sets $db-> Excute ("Set names ' UTF8 '");//Query $query= $db->execute ("select *from B"), while ($row = $query->fetchrow ()) {Print_r ( $row);} Insert $arr=array (' name ' = = ' one ', ' age ' + ', ' sex ' = ' boy ',) $db->autoexecute (' B ', $arr, ' INSERT ');//insert capital//update $sql= "Update b set name= ' wo ' where id= ' 1 '"; $db->execute ($sql);// ADODB realization of paging include_once ("adodb.inc.php"); Include_once ("adodb-page.inc.php"); session_start; Use session to save paging;//Link $db=newadoconnection ("mysql://root:my123@localhost/b") by address, $sql = "select *from B"; $page =new Adodb_pager ($sql); $page->reader (3);//show include_once in tabular form ("tohtml.inc.php"); $db =newadoconnection ("MySQL"); $ Db->connect ("LocalHost ", ' Root ', ' my123 ', ' a '); $query = $db->execute (" select *from B "); Echo rs2html ($query); 

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.