Reputation: 10897
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 ...?
Upvotes: 1
Views: 1204
Reputation: 382806
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.
Upvotes: 3