I originally wanted to learn pear, but I saw several posts on the Internet that rated adodb very highly, so I changed to this one.
ADODB has the following advantages (said online, not mine):
1. It is twice as fast as pear;
2. It supports many more database types than pear, and can even support ACCESS;
3. No need Installation, no server support is required (for novices, this is very important)
Friends who don’t know what adodb is or want to download adodb can go to this link: http://www.phpe.net/class/106 .shtml
In addition, if any brother has translated the full text of the README or knows where to find the translation, please reply to me, thank you.
Tutorial
Example 1: Select Statement
Task: Connect to an Access database named Northwind and display the first two fields of each record.
In this example, we created a new ADOC connection (ADOConnection) object and used it to Connect to a database. This connection uses the PConnect method, which is a persistent connection. When we want to query the database, we can call the Execute() function of this connection at any time. It will return an ADORecordSet object which is actually a cursor that holds the current row in the array fields[]. We use MoveNext() to move from one record to the next.
NB: There is a very practical function SelectLimit not used in this example, which can control the number of records displayed (such as Only the first ten records are displayed and can be used for paging display).
PHP:---------------------------------- -----------------------------------------------
include('adodb.inc.php'); #Load ADOdb
$conn = &ADONewConnection('access'); # Create a new connection
$conn->PConnect('northwind'); # Connect to a file named northwind's MS-Access database
$recordSet = &$conn->Execute('select * from products'); #Search all data from the products data table
if (!$recordSet)
print $conn->ErrorMsg (); //If an error occurs during data search, display error message
else
while (!$recordSet->EOF) {
print $recordSet->fields[0].' '.$recordSet->fields[1 ].'
';
$recordSet->MoveNext(); //Point to the next record
} //List display data
$recordSet->Close(); //Optional
$conn- >Close(); //Optional
?>
---------------------------------- ---------------------------------------------
$recordSet in $ The current array is returned in recordSet->fields, and the fields are numerically indexed (starting from 0). We use the MoveNext() function to move to the next record. When the database search reaches the end, the EOF property is set to true. If Execute() An error occurs, recordset returns false.
$recordSet->fields[] array is generated from PHP database extension. Some database extensions can only be indexed by numbers and not by field names. If you insist on using field name indexes, you should use the SetFetchMode function. Regardless of the format of the index, the recordset can be created by Execute() or SelectLimit().
PHP:---------------------------------------------------------- ----------------------------------
$db->SetFetchMode(ADODB_FETCH_NUM);
$rs1 = $db ->Execute('select * from table'); //Use numeric index
$db->SetFetchMode(ADODB_FETCH_ASSOC);
$rs2 = $db->Execute('select * from table'); // Using field name index
print_r($rs1->fields); # shows array([0]=>'v0',[1] =>'v1')
print_r($rs2->fields); # shows array(['col1']=>'v0',['col2'] =>'v1')---------------------- -------------------------------------------------- --------
If you want to get the record number, you can use $recordSet->RecordCount(). Returns -1 if there is no current record.
Example 2: Advanced Select with Field Objects
Search the table and display the first two fields. If the second field is in time or date format, change it to US standard time format.
PHP:------ -------------------------------------------------- --------------------------
include('adodb.inc.php'); ///Load adodb
$conn = &ADONewConnection('access'); //Create a new connection
$conn->PConnect('northwind'); //Connect to the MS-Access database named northwind
$recordSet = &$conn->Execute('select CustomerID,OrderDate from Orders'); //Search the CustomerID and OrderDate fields from the Orders table
if (!$recordSet)
print $conn->ErrorMsg(); //If the database search error occurs, the error message is displayed
else
while (!$recordSet->EOF) {
$fld = $recordSet->FetchField(1); //Assign the second field to $fld
$type = $recordSet->MetaType($ fld->type); //Format of getting field value
if ( $type == 'D' || $type == 'T')
print $recordSet->fields[0].' '.
$recordSet->UserDate($recordSet->fields[1],'m/d/Y').'
'; //If the field format is date or time, make it in American standard format Output
else
print $recordSet->fields[0].' '.$recordSet->fields[1].'
'; // Otherwise, output as is
$recordSet->MoveNext() ; //Point to the next record
}
$recordSet->Close(); //Optional
$conn->Close(); //Optional
?>
-------- -------------------------------------------------- --------------------------
In this example, we use the FetchField() function to check the format of the second field. It returns a field containing three The object of the variable
name: field name
type: the actual format of the field in its database
max_length: the maximum length of the field, some databases will not return this value, such as MYSQL, in this case the max_length value is equal to -1.
We use MetaType() converts the database format of the field into a standard field format
C: Character field, which should be displayed under the tag.
X: Text field, which stores relatively large fields Text, generally used in

What’s still popular is the ease of use, flexibility and a strong ecosystem. 1) Ease of use and simple syntax make it the first choice for beginners. 2) Closely integrated with web development, excellent interaction with HTTP requests and database. 3) The huge ecosystem provides a wealth of tools and libraries. 4) Active community and open source nature adapts them to new needs and technology trends.

PHP and Python are both high-level programming languages that are widely used in web development, data processing and automation tasks. 1.PHP is often used to build dynamic websites and content management systems, while Python is often used to build web frameworks and data science. 2.PHP uses echo to output content, Python uses print. 3. Both support object-oriented programming, but the syntax and keywords are different. 4. PHP supports weak type conversion, while Python is more stringent. 5. PHP performance optimization includes using OPcache and asynchronous programming, while Python uses cProfile and asynchronous programming.

PHP is mainly procedural programming, but also supports object-oriented programming (OOP); Python supports a variety of paradigms, including OOP, functional and procedural programming. PHP is suitable for web development, and Python is suitable for a variety of applications such as data analysis and machine learning.

PHP originated in 1994 and was developed by RasmusLerdorf. It was originally used to track website visitors and gradually evolved into a server-side scripting language and was widely used in web development. Python was developed by Guidovan Rossum in the late 1980s and was first released in 1991. It emphasizes code readability and simplicity, and is suitable for scientific computing, data analysis and other fields.

PHP is suitable for web development and rapid prototyping, and Python is suitable for data science and machine learning. 1.PHP is used for dynamic web development, with simple syntax and suitable for rapid development. 2. Python has concise syntax, is suitable for multiple fields, and has a strong library ecosystem.

PHP remains important in the modernization process because it supports a large number of websites and applications and adapts to development needs through frameworks. 1.PHP7 improves performance and introduces new features. 2. Modern frameworks such as Laravel, Symfony and CodeIgniter simplify development and improve code quality. 3. Performance optimization and best practices further improve application efficiency.

PHPhassignificantlyimpactedwebdevelopmentandextendsbeyondit.1)ItpowersmajorplatformslikeWordPressandexcelsindatabaseinteractions.2)PHP'sadaptabilityallowsittoscaleforlargeapplicationsusingframeworkslikeLaravel.3)Beyondweb,PHPisusedincommand-linescrip

PHP type prompts to improve code quality and readability. 1) Scalar type tips: Since PHP7.0, basic data types are allowed to be specified in function parameters, such as int, float, etc. 2) Return type prompt: Ensure the consistency of the function return value type. 3) Union type prompt: Since PHP8.0, multiple types are allowed to be specified in function parameters or return values. 4) Nullable type prompt: Allows to include null values and handle functions that may return null values.


Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

Video Face Swap
Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Article

Hot Tools

Atom editor mac version download
The most popular open source editor

SublimeText3 Linux new version
SublimeText3 Linux latest version

SublimeText3 Mac version
God-level code editing software (SublimeText3)

SublimeText3 English version
Recommended: Win version, supports code prompts!

SAP NetWeaver Server Adapter for Eclipse
Integrate Eclipse with SAP NetWeaver application server.