In the CodeIgniter user guide, I came across this suggestion:
开发者_开发百科In many databases it is advisable to protect table and field names - for example with backticks in MySQL.
What does it actually refer to? Protecting against ...?
To emphasize:
to protect table and field names
MySQL/SQL have reserved keywords that you can not use to name your tables or table fields or you will receive an error when executing the query. To avoid this, you need to use backtick character eg `
.
Example:
SELECT `GROUP` FROM `table`
Above GROUP
(Assuming you named your field like that without realizing it is reserved keyword) is reserved keyword and for that reason it is wrapped with backtick characters. Same is the case with table
as an example.
精彩评论