Connect to the database in php Extension

Source: Internet
Author: User
Tags php database
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.

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.