PHP High version no longer uses mysql_connect () to connect to the database

Source: Internet
Author: User
Tags deprecated mysql connect

To use PHP to generate a MySQL data dictionary export, use the following code will

$mysql _conn = mysql_connect ("$dbserver", "$dbusername", "$dbpassword") or Die ("MySQL Connect is error.");

Running the php5.5.12 version will prompt

Deprecated:mysql_connect (): The MySQL extension is Deprecated and would be a removed in the Future:use mysqli or PDO Instea D in D:\soft\develop\php\wamp\2.5\wamp\www\generate_mysql.php on line 16

It seems to be obsolete, it is not recommended to use, the program can not run. Use mysqli or PDO instead. To a higher version, This function cannot be used at all.

I want to know which PHP version will start not to recommend the use of this function, so go to the official website Www.php.net Search this function. There is such an introduction:

This extension has been deprecated since PHP 5.5.0 and will be removed in the future. You should use the mysqli or pdo_mysql extension to replace it. See MySQL: Select API Guide and related FAQs For more information. To replace this function are:

    • Mysqli_connect ()
    • Pdo::__construct ()

Address: Http://php.net/manual/zh/function.mysql-connect.php\

Inspire us to do interface services

To a higher version, there is no old version compatible with the function, why this like? From the point of view of the official PHP organization to maintain the source, this function is certainly not much advantage, to optimize the function, it is better to discard it

We are on the site and need to provide interfaces to other subsystems within the company call. There will be an interface upgrade, the original interface design is defective, do not want to repair. It is recommended to use the new version of the interface.

Thinking, why don't I get a similar promotion? Prompts the caller to upgrade to the new interface to use.

Suddenly found that from the point of view of communication costs, the information placed on the interface back to the caller, will promote the speed of improvement.

Why does the official want to disable this function? Instead of going to fix it, optimize it?

Performance considerations, safety considerations. Go to the official website for answers

Recommended API

It is recommended to use either the mysqli or Pdo_mysql extensions. It is not recommended to use the old MySQL extension for new development, as it has been deprecated as of PHP 5.5.0 and WI ll be removed on the future. A detailed feature comparison matrix is provided below. The overall performance of all three extensions are considered to being about the same (three extensions are comparable in performance). Although the performance of the extension contributes only a fraction of the total run time of a PHP Web request (Performance Considerations in PHP Web requests are a small subset of considerations, not just performance considerations. Often, the impact is as low as 0.1% (the effect is very small, 0.1%)

Crossing network Introduction, not performance considerations to discard that extension. Anyway, is to discard, do not want to maintain that. I don't know, either. However , the old extension code is also a lot of, to optimize, the interface structure has not been able to achieve the quality of ascension, it is better to open a new one?

The mysqli extension uses the MYSQLND library to manipulate the database. More recommended.

PHP High version no longer uses mysql_connect () to connect to the database

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.