What's the advantage and use of prepared statements in PHP [duplicate]
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.
精彩评论