Summary of MySQL and mysqli in PHP

Source: Internet
Author: User

First Php-mysql is the most primitive extension of PHP operation MySQL Database

and php-mysqli, the letter I represents the improvement, to mention the relative advanced function.

Recommend learning and using mysqli

MySQL is a non-holding connection function and Mysqli is a permanent connection function

In other words, MySQL will open a connected process each time the link

Mysqli multiple runs mysqli will use the same connection process, thus reducing the server overhead

By default, starting with PHP5, PHP does not automatically turn on MySQL support, but instead puts it into the extension function library. So the user needs to open the MySQL library in the extension function library

First open php.ini find "; Entensions=php_mysql.dll", remove the previous semicolon comment

Save restart Apache or IIS

The Phpinfo () function can then be used to check if the pairing is successful, and if the displayed PHP environment configuration information has a MySQL project, it indicates that MySQL support has been successfully turned on.


Mysqli.dll is a way of allowing the database to be manipulated as an object or a process, and it is easy to use. Here is a comparison of a few common operations and mysql.dll.


1:mysql.dll (can be understood as a functional approach):

Mysqli also have a procedural approach, but start with the mysqli prefix, the others are similar.

If Mysqli is manipulated in a procedural way, some functions must specify a resource

For example, Mysqli_query (resource Identifier, SQL statement), and the parameter of the resource identifier is placed in the preceding

The resource identifier for the mysql_query (SQL statement, optional) is placed in the back and can be unspecified, which defaults to the last open connection or resource.

And the mysql_select_db and mysqli_select_db parameters are just the opposite.

It is important to emphasize that php5.5 cannot use mysql_query and needs mysqli

That's why I came into contact with mysqli. Manual funny

2mysqli.dll (object mode):

Summary of MySQL and mysqli in PHP

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.