What kind of computing is used to connect to the MySQL database during actual development of small and medium-sized websites?

Source: Internet
Author: User
Tags mysql functions
In the actual development of small and medium-sized websites, what kind of computing is used to connect to the MySQL database? it is a traditional mysql function.
Or mysqli function

Or the PDO interface method.

What are the characteristics and applicability of these three methods?

In addition, I would like to ask:
Set the character set. Strictly speaking, should the character set name be enclosed by quotation marks? I think the character set name is a string constant, which may be better, such as the execution speed.
Mysql_query ("set names 'gb2312 '");


Reply to discussion (solution)

It should be enclosed in quotation marks, but I don't know anything else. this is what I wrote in the book.

What kind of computing?

Most of the time, PDO can be used to easily replace various databases, such as MSSQL.
If it is a small system, you will consider using Mysqli
Of course mysql is also in use...

Mysql <mysqli <PDO

I can see that in

How can I earn points? who knows?

The new php version uses pdo as the mysql connection method by default, so it is obvious that pdo is becoming more and more popular.

Give priority to pdo and mysqli, because mysql functions are early php products, which are highly risky and vulnerable to SQL injection attacks. While mysqli and pdo adopt placeholder preprocessing, which makes it safer.

A small website can be used easily.

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.