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