Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

PHP Mysql support: is it mysql or mysqlnd?

2025-04-02 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Database >

Share

Shulou(Shulou.com)06/01 Report--

You are using one of the alternate repositories to install a modern version of php, and suddenly you are faced with a puzzling choice. You want to support mysql (mysqli or PDO-mysql) in the php program. What would you choose?

First, you should probably use PDO. It's just a cleaner database interface than mysqli, and it's often a supported option if you use an ORM like Doctrine2.

But you may have found that installing the PDO package does not allow you to support MySQL.

So what are these two packages? Once we have set webtatic as a buyback, let's see what yum under Centos shows us:

* webtatic:us-east.repo.webtatic.com

=

Php56w-mysql.x86_64: PHP applications for using MySQL databases

Php56w-mysqlnd.x86_64: a module for PHP applications that use MySQL databases

In short, the mysql extension, the mysql library, refers to Oracle / mysql

... General client library

It's called libmysql.

This is the original php method that supports mysql. MySQL provides a client-side api library and uses the c library to create a php extension that relies on libmysql to implement the famous mysql_ function that allows php to communicate with mysql.

The mysqlnd package, where nd stands for "native driver", is the result of a project that makes mysql work best in the PHP language. Quote the mysql website again:

The mysqlnd library is highly optimized to be tightly integrated with PHP. The MySQL client library cannot provide the same optimization because it is a generic client library.

The mysqlnd library integrates seamlessly into PHP using PHP's internal C infrastructure. In addition, it uses PHP memory management, PHP Streams (I / O abstraction), and PHP string handling routines. For example, mysqlnd uses PHP memory management to save memory by using read-only variables (copy on write) and to adapt mysqlnd to PHP memory limits.

In addition to these benefits, there are some interesting enhancements and support for plug-ins that may be of particular interest to you as a developer or system administrator.

In general, your code should not be broken, because api should be the same as the old mysql library under mysqlnd.

Conclusion

In short, you want to use mysqlnd now and in the future.

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Database

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report