1. How to prevent SQL injection
- Check the variable type, and if it is shaping, use the Intval method to convert to int
- The string type uses the Addslashes function to filter special characters (it adds a backslash escape before the specified predefined characters, which are: Single quotation mark (') Double quotation mark (") backslash (\) NULL)
- If you are using MySQL, use mysqli_real_escape_string to filter the characters, but it is not completely prevented,
- In fact, binding variables using precompiled statements are the best way to prevent SQL injection , and the semantics of using precompiled SQL statements will not change.
https://www.zhihu.com/question/22953267
2, MySQL Those keywords can not use the index?
- Not in,! =, <>
- Like "%xxx"
- column for function operations.
- WHERE index=1 OR a=10
- A String type field (such as a phone number) that has a numeric value stored, remember not to drop the value quotation marks when querying, otherwise it is not OK to use the field related index.
3. What is the type of MySQL index?
Primary key index, unique index, federated Index, normal index
4. What is the main purpose of vertical split table optimization?
Each update causes the table's query cache to be emptied. So, you can put this field in another table so that you don't have to keep reading the fixed field, because the query cache will help you add a lot of performance.
5, table horizontal split There are several options?
Splitting defects by time will cause the old data query frequency is low, the query pressure of the new table is big
Use hash distribution by user ID, disperse evenly, but need to re-hash when adding table
MySQL related issues