How does MySQL deal with PHP?

Source: Internet
Author: User
Tags php mysql python mysql
How does MySQL deal with PHP?

Reply content:

How does MySQL deal with PHP?

I think the question should be "How does PHP deal with MySQL more appropriately?"

There are several layers of answers.

First of all, it can be said that PHP with the C language extension to deal with MySQL. PHP can be extended in C, other languages like Python, Ruby, and Perl. So in many cases in C language to write a little php/python extension, can be the original C-language MySQL driver into Php/python MySQL driver, in fact, finally in the call MySQL version of the C-language dynamic library (. DLL or. So)

So many things, like OpenGL libraries, crypto libraries, memcache libraries, and so on.

Another layer down, we can also say that PHP is connected via sock or TCP to the MySQL server. If the MySQL server and PHP are running on the same machine, then you can communicate with the MySQL server via sock or 127.0.0.1 TCP connection, which means that cross-process communication (even on-premises, inter-process communication often uses the 127.0.0.1+ port number, It is said that the kernel is optimized, will not go to the network card, performance is very high)

If not on the same machine, then the network card is the TCP connection

Finally, is not all driver to use the C language this layer? If the protocol is simple, it is possible to implement a driver in the PHP layer, and then call the PHP socket library to implement. But in terms of performance considerations, protocol complexity (MySQL server protocol), future maintainability (MySQL version upgrade), so basically no one is doing so.

    • PHP MySQL operation, why to return a string array, do not return the actual data type?
    • Php-mysqli Source
  • 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.