Analysis of the difference between MySQL and mysqli

Source: Internet
Author: User
Tags php programming php programming language
This article describes the PHP in the use of MySQL and mysqli in the usage of some differences, there is a need for friends reference.

MySQL and mysqli differences: MySQL and mysqli (MySQL improved) is a library functions (or Extension) in the PHP which was used to ACC ES MySQL database. Mysqli is the improved version of MySQL which support OOPS. The mysqli extension allows you to access the functionality provided by MySQL 4.1 and above.

MySQL is a non-holding connection function and Mysqli is a permanent connection function. MySQL each time the link opens a connected process and mysqli runs multiple times mysqli will use the same connection process, thereby reducing the server overhead. If using new mysqli (' localhost ', usenamer ', ' Password ', ' databasename '), always error, Fatal error:class ' mysqli ' not found in ... Then check to see if the mysqli is open. Mysqli class is not the default open, win under to change php.ini, remove php_mysqli.dll ago, Linux to the mysqli compiled into.

In relation to PHP programming language, MySQL was the old database driver, and mysqli is the improved driver. Mysqli takes advantage of the newer features of MySQL 5. Lifted verbatim from the Php.net site:-object-oriented interface-support for Prepared statements-support for Multiple S Tatements-support for transactions-enhanced debugging capabilities-embedded Server Support

You have the choice of using MySQL, mysqli, or PDO essentially.

If you ' re simply looking for a relational database, you need look no further than MySQL, though there is many options Ava Ilable. You can use DBD, Postgres, MySQL, MSSQL, SQLite, etc etc etc...

Hthsource (s): Http://www.php.net/manual/en/mysqli.over ...

Mysqli usage: $mysqli = new mysqli (' localhost ', ' my_user ', ' My_password ', ' my_db '), MySQL usage: $link = mysql_connect (' example.com:3307 ', ' mysql_user ', ' Mysql_password '); When dealing with Chinese garbled problems, in $link = mysql_connect (' example.com:3307 ', ' Mysql_ User ', ' Mysql_password '); After setting the connection character set: mysql_query ("Set names UTF8"); Note: You cannot write Utf-8.

Set the operating database: mysql_select_db ("my_db"), while using MYSQLI, the database name is a parameter of the Mysqli construction method, so setting the connection character set does not work at this point.

  • 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.