PHP connection MySQL data operation points, Phpmysql data points _php Tutorial

Source: Internet
Author: User

PHP connection MySQL Data operation Point, phpmysql data points


The MySQL extension library operates the MySQL database in the following steps:
1: Get the connection.
2: Choose the Library.
3: Set the action encoding.
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. (such as Select)
4.4:DTL: Data things language.

5: Receive the returned result and process.
6: Disconnect.

The specific sample code is as follows:
Copy the Code code as follows:
<?php
1: Connect to 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 manipulate
mysql_select_db ("test");
3: Send SQL command
mysql_query ("Set names UTF8");//Set query encoding
$sql = "Select *from test1";
$res =mysql_query ($sql, $con);
4: Return results (by row traversal)
while ($row =mysql_fetch_row ($res)) {
echo "$row [0]-------------$row [1]-----------$row [2]-----------$row [3]-----------$row [4]". '
';
}
5: Release the resource, close the connection
Mysql_free_result ($res);
Mysql_close ($con);
?>

To illustrate, all of the operations here are in the memory of the operation, can not be taken for granted is what things, so say, understand some of the underlying things still have certain benefits.

http://www.bkjia.com/PHPjc/970991.html www.bkjia.com true http://www.bkjia.com/PHPjc/970991.html techarticle PHP connection MySQL data operation Point, phpmysql data points MySQL extension library operation MySQL database steps are as follows: 1: Get the connection. 2: Select the library. 3: Set the action encoding. 4: Hair ...

  • Related Article

    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.