What is parameterized query?

后端 未结 4 2177
攒了一身酷
攒了一身酷 2020-11-21 11:12

What is a parameterized query, and what would an example of such a query be in PHP and MySQL?

4条回答
  •  挽巷
    挽巷 (楼主)
    2020-11-21 11:46

    A parameterized query is a query in which placeholders are used for parameters and the parameter values are supplied at execution time.

    Why use Parameterized Query

    1. The most important reason to use parameterized queries is to avoid SQL injection attacks.
    2. Secondly parameterized query takes care of scenario where sql query might fail for e.g. inserting of O'Baily in a field. Parameterized query handels such query without forcing you to replace single quotes with double single quotes.

提交回复
热议问题