PHP(mysqli或pdo)如何运行MySQL命令? [关闭]

When using mysqli or PDO in a PHP script what are the mechanics that take place for the sql query to run?

Does the mysqli module run shell_exec() with a mysql command? I'm sure there is something more here.

Edit

More specifically what I wanted to know was what is the process that PHP takes to actually make a MySQL call, what are the mechanics involved for PHP to have access to the database.

There is a thing called Mysql C API.

Both PHP extensions are written by implementing low-level C functions from this API.

It connects directly over a socket to the server. There is no way to have connection pooling if you're just doing shell_exec(), which you may have noticed is an option. Not only that, but running another executable for every single query is insanely slow. As the other answer has mentioned, PHP uses C-bindings for Mysql which do all the hard work reading/writing sockets.