-2

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?

Community
  • 1
  • 1
Tural Ali
  • 22,202
  • 18
  • 80
  • 129

1 Answers1

3

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.

Community
  • 1
  • 1
Quentin
  • 914,110
  • 126
  • 1,211
  • 1,335