Blindly Replacing mysql_ Functions with mysqli_: A Cautionary Tale
In PHP 5.5, the mysql_ functions were deprecated and have since been removed in PHP 7. This raises the question of whether one can simply replace all mysql_ functions with mysqli_ functions without encountering any adverse effects.
The answer is a resounding no.
Functional Differences
While the mysql_ and mysqli_ functions share a similar naming convention, they are not equivalent in functionality. For instance:
Recommendations
It is not advisable to blindly replace mysql_ functions with mysqli_. Instead, it is necessary to carefully update the code to use mysqli_ functions correctly. This involves:
Conversion Tool
To ease the migration process, there is a converter tool available: https://github.com/philip/MySQLConverterTool. However, it is important to note that the converted code still requires manual review and testing.
Conclusion
Replacing mysql_ functions with mysqli_ requires some effort and attention to detail. While the functions share the same function names, their internal implementations differ. By carefully updating the code and verifying its functionality, developers can ensure a smooth transition away from deprecated functions.
Disclaimer: All resources provided are partly from the Internet. If there is any infringement of your copyright or other rights and interests, please explain the detailed reasons and provide proof of copyright or rights and interests and then send it to the email: [email protected] We will handle it for you as soon as possible.
Copyright© 2022 湘ICP备2022001581号-3