The MySQL extension library operates the MySQL database in the following steps:
1: Get the connection.
2: Select the stacks.
3: Set the Operation code.
4: Send SQL instructions (MySQL database can be divided into four kinds of instructions:
4.1:DDL: Data definition language.
4.2:DML: Data manipulation language (e.g. curd);
4.3:DQL: Data Query Language. (for example, select)
4.4:DTL: The language of data things.
5: Receive return results, and process.
6: Disconnect the connection.
The specific sample code is as follows:
Copy Code code as follows:
<?php
1: Connecting the database
$con =mysql_connect ("localhost", "root", "Toor");
Error if no connection is successful
if (! $con) {
echo "Connection Failed";
Exit ();
}
2: Select the database to operate
mysql_select_db ("test");
3: Send SQL instructions
mysql_query ("Set names UTF8");//Set query encoding
$sql = "Select *from test1";
$res =mysql_query ($sql, $con);
4: Return the result (return by row traversal)
while ($row =mysql_fetch_row ($res)) {
echo "$row [0]-------------$row [1]-----------$row [2]-----------$row [3]-----------$row [4]. ' <br/> ';
}
5: Free resources, close the connection
Mysql_free_result ($res);
Mysql_close ($con);
?>
To illustrate, all the operations here are in the memory inside to operate, can not take for granted is what things, so to know some of the underlying things still have certain benefits.