开发者

What's the advantage and use of prepared statements in PHP [duplicate]

This question already has answers here: Closed 11 years ago. 开发者_运维知识库

Possible Duplicate:

PHP PDO prepared statements

prepared statements - are they necessary*

Recently, heard about php prepared statements. Nearly all hi-rep php developers use php prepared statements. Can anyone explain me what's the main advantage and use of php prepared statements?


Prepared statements allow you to make multiple similar queries more efficiently. You can prepare (for example) an insert statement, then loop over it with multiple bits of data and get a performance boost as the database has less work to do as it doesn't have to set it up each time.

As a side effect, people using prepared statements tend to use bound parameters too, and these provide protection from SQL injection.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜