开发者

Protect Table and Field Names

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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜