Php:pdo Prepare pretreatment

Source: Internet
Author: User

Many mature databases support the concept of preprocessing statements (Prepared statements). What are they? You can think of them as a compiled SQL statement template that you can customize with different variable parameters. Pre-processing statements have two main advantages:

Queries need to be parsed (or prepared) only once, but can be executed multiple times using the same or different parameters. When the query is ready (Prepared), the database parses, compiles, and optimizes its plan to execute the query. For complex queries, this process can take a lot of time to slow down your application if you want to repeat many of the same queries with different parameters but with the same structure. By using a pre-processing statement you can avoid repetitive analysis, compilation, optimization of the link. Simply put, pre-processing statements use fewer resources and execute faster.

The parameters passed to the preprocessing statement do not need to use quotation marks, and the underlying driver will handle this for you. If your application exclusively uses preprocessing statements, you can be confident that no SQL injection will occur. (However, if you are still building other parts of the query with untrusted input, this is still risky)

Just because preprocessing statements are so useful, it becomes the only simulation implementation that PDO provides for a database that does not support this feature. This allows you to use a unified data access specification without having to worry about whether the database itself has this feature.

Php:pdo Prepare pretreatment

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.