2

I am in the process of connecting a Node.JS server with a PHP application (on the same VPS) and a solution that I have found was to communicate via cURL.

I am thinking of going one step further and instead of have an HTTP server running on a custom port, I will write a Node.js socket server that accepts a custom protocol, and my PHP would connect via raw sockets.

The reason is because I assumed that this is how PHP connects to a MySQL server (obviously via some sort of MySQL protocol).. am I right? Because I can connect to MySQL from a remote PHP application without any problems, so there must be some sort of network communication between the two!?

So my question is, can someone tell me how PHP connects to MySQL? There must be networking somewhere along the line.

EDIT: I know the MySQL runs on port 3306; this has got to be relevant to the PHP MySQL APIs..

4

3 回答 3

4

PHP 和其他语言将使用mysql 客户端库。该库将依次实现手册中详述的 MySQL 协议

于 2013-05-25T23:40:45.043 回答
3

no it connects with high performance connectors not sockets directly http://dev.mysql.com/downloads/connector/

in fact the question is more of how does a particular data consumer connect to mysql, such as PHP (

mysql_
mysqli_
pdo

), python, ruby, etc. the above answer is the same

于 2013-05-25T23:31:45.010 回答
3

Apache doesn't speak to MySQL, node.js/PHP does the work. Apache just runs the script you requested.

于 2013-05-25T23:32:18.740 回答