How to connect to the database in the php extension?
Reply content:
How to connect to the database in php Extension
You want to use C to write PHP extensions and perform database operations in extensions. If you are sure you want to do so, you must operate the database in C code and use the database's C language API.
BTW: this is not a good solution. You can use C to write a Server, and then PHP interacts with the Server to implement the function. Connecting to the database and implementing data operations is not the bottleneck of PHP. It is not appropriate to assign this part to the extension. In other words, even if you use extensions to implement database operations, the performance and efficiency in most cases will not be better than the native PHP database driver.
Mysql_connect (host, user, pass)
Isn't that connecting to the database in expansion? Look at the source code
This problem is quite strange. Why is it necessary to connect to the database in expansion? The php database connection function calls the C language API of mysql in the kernel.