PHP AdoDb 1.99 version manual Chinese translation

xiaoxiao2021-03-06  42

http://www.moocky.net/manual/adodb.gb.htm

PHP AdoDB 1.99 Handbook Chinese Translation (TRIPC) Thanks Notes

PHP ADODB 1.99 manuals Chinese Translation Author: Tripc ------------------ ADODB PHP in the database support is very commendable, almost all of the well-known database The system has a corresponding functional group support, and the support is very complete. But unfortunately, each group of database support functions have great differences in the name or number of structures, which makes PHP's system developers will always feel painful when they face the replacement database. Does this question have not a solution? Oh, of course, the answer is the PHP object I want to introduce now. AdoDB provides a complete method and property that allows engineers to control the database system. It is better to remember its function. Because of different database systems, as long as you modify a property value, AdoDB will automatically basis Set the correct PHP function. In addition, up to the database system modification to modify the SQL instruction, your PHP system can be replaced to another in the shortest time. If you write a program, you can properly plan the SQL instruction, then almost. After the above introduction, I believe that you have already understood the function of AdoDB, and the following is a detailed introduction of AdoDB. Get adodb you can get the latest version of AdoDB at http://php.weblogs.com/adoDB. When I wrote this article, the latest version is 1.99 version, copyright pick BSD-style and LGPL double rail system, some words are freeware, no restrictions. But after getting AdoDB, it is best to look at the relevant copyright description and usage, and follow this article to avoid errors. It is quite easy to use AdoDB to use AdoDB. After getting the compressive gear, I suggest that the entire content is solved in the adoDB directory. Then you can use this article and study the example inside, put it in the Test directory inside. Since Adodb attached very complete detailed, the following description of most of the readme.htm from AdoDB, not all content, I have removed some content I don't use, and the version difference description, why writing support ADODB drivers, etc., are unrelated to applications. Want to know the readers of all content or you can go to Readme.htm yourself.

Introduction Characteristic installation starts AdoDB

ADONEWCONNECTION NEWADOCONNECTION Support for Database Learning Manual

Example 1: SELECT Sample 2: Advanced SELECT Example 3: Insert Example 4: Error and RS2HTML Examples 5: MySQL and Menu Example 6: One Connection Two Database Example 7: Generate Update and New SQL Directive Example 8 : Use the next and the next and the previous actual roll-off error handling and PEAR error data set to take the test manual

Adoconnection

Link Database: Connect PConnect execute SQL: Execute CacheExecute SelectLimit CacheSelectLimit Prepare PrepareSP GetOne GetRow generate update / add: GetUpdateSQL GetInsertSQL BLOB: UpdateBlob UpdateClob UpdateBlobFile feed / vol Page: PageExecute CachePageExecute clear: CacheFlush Close Transaction: BeginTrans CommitTrans RollbackTrans extract data: $ ADODB_FETCH_MODE BlankRecordSet string: Concat qstr date: DBDate DBTimeStamp UnixDate UnixTimeStamp "column" Manager: affected_Rows Insert_ID GenID error handling: ErrorMsg ErrorNo data dictionary: MetaDatabases metaTables MetaColumns MetaColumnNames opposition: Bind ADORecordSet take single record (not explain?): fetchRow FetchInto FetchObject FetchNextObject GetRowAssoc fields GetAssoc take all records: GetArray GetRows scroll: move MoveNext MoveFirst MoveLast AbsolutePosition CurrentRow AtFirstPage AtLastPage AbsolutePage menu production: GetMenu GetMenu2 date: UserDate UserTimeStamp UnixDate UnixTimeStamp record information: RecordCount PO_RecordSet field Feed: FieldCount FetchField MetaType clear: Close RS2HTML Public Volume Example Introduction Since PHP's data inventory is not standardized Therefore, we need a group of function libraries or categories to hide the differences between inter-different database functions, allowing us to switch the database very simple, and this is the purpose of AdoDB. Adodb currently supports Mysql, Oracle, Microsoft SQL Server, Sybase, Sybase SQL Anywhere, Informix, PostgreSQL, Frontbase, Interbase (Firebird, and Borland), FoxPro, Access, ADO, and ODBC. AdoDB also has a report of Progress and DB2 through ODBC, and we hope that more people can provide drive interfaces to support more databases. The PHP4 support link change variable (session variables), the user can reach the connection information through AdoDB to achieve real portability and elasticity, relevant usage and information, please refer to the example of AdoDB-session.php. In addition, if you have to write a SQL code with a highly portable, you can also read this article with http://php.weblogs.com/portable_sql. Characteristic

For engineers who are familiar with Windows, AdoDB is easy to use because there are many features in AdoDB and the Microsoft's ADO is very similar. Unlike other PHP library categories, most of them focus on things related to the SELECT directive, while AdoDB provides additional support for INSERTS and UPDATE, and can quickly connect to multiple databases. The method provided by the methods provided, the sum of the strings, the string tag character difference processing (the connection and tag symbols of some database strings and the marker symbols are different) Type control systems are built-in So we can set or describe the same data type like char, text and string in different databases. It is easier to transplant because all programming codes depending on the database are hidden in the rear end, so the user no longer needs logic in the transplant category. Support the PHP4 linking variable, please test adoDB-session.php. Installation First To make sure the PHP version you are using is 4.01pl2 or the subsequent version (because the adoDB uses the request_Once and include_once two functions). Unzip all files to a directory that your web server can access. To test AdoDB you need a database, open TestDatabase.inc.php file, and modify the number of links to suit the database you are using. This program will establish a new information sheet in your database to support our testing and examples. In this way, you have installed it. When you start AdoDB When you want to execute AdoDB, at least two files are to be contained, the first is AdoDb.inc.php, which contains the functions to be used in all database classes. The program code on the database is placed in the adoDB - ????. Inc.php file. For example, to connect a mysql database: include ('/ path / to / set / here / adoDb.inc.php');

$ conn = & adonewconnection ('mysql'); Whenever you need to connect to a database, you must use the Adonnection () function to establish a link. AdonewConnection accepts a selective parameter, . If there is no parameter to be specified, it will use the last repository that is loaded by AdoloadCode (). NewAdoconnection () is another same function. When you build a link to a link, you don't really connect your database. You still need to use $ conn-> connect () or $ conn-> pConnect () to complete the true link. You can take the example in the teaching manual, and do a more in-depth understanding of the above instructions. Supported Database Name Test Status Database RecordCount () Supports the Drive Program Work System Need to Install ACCESS B Microsoft Access / Jet. An ODBC / DSN is required. Y / N ODBC Windows Only ADO B Generally does not set the DSN link, using OLEDB to provide better efficiency without setting ADO. • ADO or OLEDB Provider Windows Only ADO_ACCESS B Microsoft Access / Jet Allows the DSN link, which is not set, using OLEDB to provide better efficiency. Y / N Ado or OLEDB Provider Windows Only ADO_MSSQL B Microsoft SQL Server Transmits not to set DSN links, using OLEDB to provide better performance. Y / N Ado or OLEDB Provider Windows Only DB2 C DB2. You can have trustworthy operational effects through ODBC. Y / N DB2 CLI / ODBC interface Unix and Windows. Unix install hints. Vfp A Microsoft Visual FoxPro, the need to establish a ODBC / DSN Y / N ODBC Windows only fbsql C FrontBase. Y? Unix and Windows ibase B Interbase 6 or earlier version of. Some users report to link $ db-> pconnect ('localhost: c :/ibase/employee.gdb', "sysdba", "masterkey"), now not support affected_rows method Y / N Interbase Client UNIX and Windows firebird C interbase Firebird version of Y / N Interbase client Unix and Windows borland_ibase C Borland's Interbase 6.5 or later Y / N Interbase client Unix and Windows informix C Informix Y / N Informix client Unix and Windows mssql a Microsoft SQL Server 7. also It can be well operated with Microsoft SQL Server 2000. But there are still some problems in the date format. For example, on the retrieval value of the date time, the second number value will not be sent.

Y / N Mssql client Unix and Windows.Unix install howto. Mysql A MySQL does not support transaction processing Y / N MySQL client Unix and Windows mysqlt or maxsql A MySQL support transaction processing Y / N MySQL client Unix and Windows oci8 A Oracle 8/9 Supports more features than Oracle drivers (for example: Affected_Rows). Before connecting, you may need to match the environment variable ('oracle_home = ...') has two ways to connect, using the server IP or Service Name: PConnect ('Serverip: 1521', 'SCOTT', 'Tiger', 'Service') PConnect ('', 'Scott', 'Tiger', 'TNSName'). Y / N Oracle Client Unix and Windows OCI8PO A Oracle 8/9 Portable Driver Y / N Oracle Client UNIX and Windows ODBC A Standard ODBC with PConnect ('DSN', 'User', 'PWD'). ? Depends on database ODBC Unix and Windows. Unix hints. Odbc_mssql C connection ODBC MSSQL Y / N ODBC Unix and Windows. Odbc_oracle C with ODBC connection ORACLE Y / N ODBC Unix and Windows. Oracle C support the old Oracle 7 client API. does not support $ ADODB_FETCH_MODE. Y / N Oracle client Unix and Windows postgres A PostgreSQL does not support LIMIT command. Y PostgreSQL client Unix and Windows. postgres7 A PostgreSQL support LIMIT and other version 7 functionality Y PostgreSQL client Unix and Windows. sqlanywhere C Sybase SQL Anywhere Y / N SQL Anywhere ODBC Client? Sybase C Sybase. Y / N Sybase Client UNIX and Windows. Unix Hints. The code of the test status bar is as follows: A = Many people have verified and tested, the reliability is the highest. B = Test and used, but there may still have some functions that have not been achieved. C = user-configured or trial driver, may not fully support the functionality of AdoDB. "RecordCount () support or not," refers to whether the recordcount () function will return to the record written acquired with the SELECT directive (not supported when not supporting). If the value of this field appears y / n, it means that when the whole variable $ adoDB_counter = true, this is a mode of mode. It should be noted that if you predict that the record has a lot, it is best to set this value to false, which is turned off this simulation function, because it will take a lot of memory, for quick get it. use. Since this variable is checked at each execution, you can selectively use or not use.

All databases support $ adoDB_Fetch_Mode support AdoDB_Fetch_num (in the field order) and adoDb_fetch_assoc (with the field name), two modes. The value is set to adoDB_FETCH_DEFAULT, which is determined by the functionality of the database, so it does not have portability, and AdoDB_Fetch_both (dual mode access) is also the same. Learning Manual Example 1: SELECT Directive Task: Connect to Access's NorthWind DSN, then display the head in each column. (Northwind Northern Database, DSN set by ODBC, is an Access's Standard Example Database) In this example, we create an Adoconnection object, which represents the link of the database. The connection is initialized by a PConnect function and then continues to connect. When we want to query the database at any time, we call the adoConnection.execute () function, which will return an Adorecordset object. In fact, it is just a indicator pointing to the Fields [] array, the current record, and we use molent () to move between records. Note: Another very useful function SelectLimit does not use in this example, which allows us to limit the displayed data pen.

INCLUDE ('adodb.inc.php'); # a a

$ conn = & adonewconnection ('access'); # 建立 a link

$ conn-> pConnect ('northwind'); # links to MS-Access North San Database

$ RecordSet = & $ conn-> execute ('select * from products ";

IF (! $ recordset)

Print $ conn-> errormsg ();

Else

While (! $ recordset-> EOF) {

Print $ RecordSet-> Fields [0]. ''. $ recordset-> fields [1]. '
'

$ RecordSet-> MoveNext ();

}

$ RecordSet-> Close (); # Selective Execution

$ conn-> close (); #Elective execution

"In this example, $ RecordSet returns a record in the $ RECORDSET-> Fields array, currently pointed to. With the column number index, the start value is 0. We use the MoveNext () function to move to the next record. When the last pen, the EOF property is set to true. When the execute () function performs an error, it will return a false value, not a Recordset object. $ RecordSet-> Fields [] Array is generated by the PHP Database Extension Function Library. Some database expansion function libraries support only by numbered, without supporting the name index. To force the use of the column name index, that is, use a closed array, use the $ adoDb_fetch_mode all-in number to set. When a data set is established by the execute () or the SelectLimit () function, it will be stored and stored in such a setting mode. $ AdoDb_fetch_mode = adodb_fetch_num;

$ r1 = $ db-> execute ('select * from table ";

$ AdoDb_fetch_mode = adoDb_fetch_assoc; $ r2 = $ db-> execute ('select * from table ");

Print_r ($ r1-> fields); # shows array ([0] => 'v0', [1] => 'V1')

Print_r ($ r2-> fields); # shows array (['col1'] => 'V0', ['COL2'] => 'V1') The above example statement, if you want to access the field in order, Set the value of $ adoDB_fetch_mode to adoDb_fetch_num, you must set the value to adoDb_fetch_assoc in a closed array (in the field name). To get the number of records selected, you can use $ RecordSet-> RecordCount () method. Note that if you cannot determine the number of recorded records, -1 will be returned. Example 2: Advanced SELECT Directive (Using the Field Item) Task: Select a data sheet to display the front bin. If the second column is a date or time type field, it format it into a US format.

INCLUDE ('adoDb.inc.php');

$ conn = & adonewconnection ('access ");

$ conn-> pconnect ('northwind');

$ RecordSet = & $ conn-> execute ('select customerid, orderdate from orderers ";

IF (! $ recordset)

Print $ conn-> errormsg ();

Else

While (! $ recordset-> EOF) {

$ fld = $ recordset-> fetchfield (1);

$ TYPE = $ recordset-> Mettype ($ fld-> type);

IF ($ TYPE == 'D' || $ type == 't')

Print $ RecordSet-> Fields [0]. ''.

$ RecordSet-> Userdate ($ RecordSet-> Fields [1], 'm / d / y'). '
';

Else

Print $ RecordSet-> Fields [0]. ''. $ recordset-> fields [1]. '
'

$ RecordSet-> MoveNext ();

}

$ RecordSet-> Close (); #boptional

$ conn-> close (); #boptional

> In this example, we use the fetchfield () function to check the data type of the second field. This will return a piece of item that at least three fields, and the column describes the following:

Name: Maitudi TYPE: The data of the field is native model Native FIELD TYPE OF Column Max_length: The maximum length of the field, partial data library is mysql, does not return the correct value of the field, in this example, It will pass back. Then we use metatype () to convert the original type of universal type, the current universal type is defined as follows: C: Character field, you should use the tag to take the value. X: Text, long text field, use the