mysql_ functions vs. mysqli object approach

mysql_ functions vs. mysqli object approach

Is it a bad idea to use mysql_ functions directly instead of going through the mysqli object approach?

    Requires Free Membership to View

    When you register, my team of editors will also send you resources covering Linux administration and management; integration and interoperability between Linux, Windows and Unix; securing Linux and mixed-platform environments; and migrating to Linux.

    Margie Semilof, Editorial Director

    By submitting your registration information to SearchEnterpriseLinux.com you agree to receive email communications from TechTarget and TechTarget partners. We encourage you to read our Privacy Policy which contains important disclosures about how we collect and use your registration and other information. If you reside outside of the United States, by submitting this registration information you consent to having your personal data transferred to and processed in the United States. Your use of SearchEnterpriseLinux.com is governed by our Terms of Use. You may contact us at webmaster@TechTarget.com.

The mysql_ functions provides a procedural interface to MySQL, and are adequate for many applications. However, they do not take advantage of the newer features to MySQL, including prepared statements and the multiple result sets from stored procedures. For new development, then, mysqli is the better choice. You can still choose whether to use it in a procedural or object-oriented manner. See http://dev.mysql.com/doc/refman/5.0/en/php.html for more details.

Also note that mysqlnd, a replacement for libmysql, is under development. This new library does not indicate changes to PHP scripts, which will continue to use mysqli functions. Rather, it is a new way for PHP to connect to MySQL "behind the scenes," and offers some performance improvements. See http://dev.mysql.com/downloads/connector/php-mysqlnd/ for more information.

This was first published in May 2007