In Yii 2.0, use the like operator to find \ , the result is empty analysis, because the official bug of the mysql version
1. Request parameter: filter[and][0][or][0][title][like]=\, the generated sql is as follows, the search result is empty. as shown in Figure 1
`pa_plan`.`title` LIKE '%\\\\%'
2. Check the value of the field title in the table plan, one of the records exists \. In theory, it is possible to query a record. as shown in Figure 2
3. Execute SQL in Navicat for MySQL, the MySQL client software, 4 backslashes, and the search result is empty. as shown in Figure 3
SELECT * FROM `pa_plan` WHERE `title` LIKE '%\\\\%'
4. Check the sorting rule of the field title in the table plan, its value is: utf8mb4_unicode_ci. as shown in Figure 4
5. Execute SQL, 5 backslashes (add 1 root), and query a record. as shown in Figure 5
SELECT * FROM `pa_plan` WHERE `title` LIKE '%\\\\\%'
6. Modify the sorting rule of the field title in the table plan, its value is: utf8mb4_general_ci. as shown in Figure 6
7. Execute SQL, 4 backslashes, and query a record. as shown in Figure 7
SELECT * FROM `pa_plan` WHERE `title` LIKE '%\\\\%'
8. Check the official MySQL document, refer to:https://bugs.mysql.com/bug.php?id=81990. In mysql version: 5.6.31/5.7.13, the sorting rule, whose value is: utf8mb4_unicode_ci, all need to search for \, and then add 1 root, you can search for results. This bug was fixed in MySQL version: 8.0.18. as shown in Figure 8
9. Query the current database version: 5.7.19. as shown in Figure 9
10. Follow-up to confirm whether you can generate SQL for like search in Yii 2.0, and automatically add another \ . This problem should be suspended first. Because searches like other special characters are normal.
![请求参数:filter[and][0][or][0][title][like]=\,生成 SQL 如下,查找结果为空](https://www.shuijingwanwq.com/wp-content/uploads/2021/07/1.png)







