Today, when querying the data, a small problem is that when querying data with TP5.0, a function is needed find_in_set for the purpose of this function is to give an example first:
There is an article table with a Type field, which stores the article type, there are 1 headlines, 2 recommendations, 3 hotspots, 4 graphics and so on. Now there is an article that he is a headline, hot, or graphic, type in the format of 1,3,4 storage. So how do we use SQL to find 4 of all types of text in the type?? Then we need to use the Find_in_set function for more details on this function Portal: http://www.cnblogs.com/xiaoxi/p/5889486.html
Said so much below look at the examples in TP5 I know there are two ways
The first form of an array is an exp is an expression of TP
The Recommend_status field exists in the database in the form of the Find_in_set function.
1 $map []=[' exp ', ' Find_in_set (3,recommend_status) ']; 2 $map [' game_status '] = 1; 3 4 db::name (' Game ')->where ($map)->select ();
The second type is in string form
db::name (' Game ')->where ("Game_status=1 and Find_in_set (' 3 ', Recommend_status)")->select ();
Second, you can also use a string expression in the where condition when using other query methods
Db::name (' Game ')->where (' Recommend_status ', ' exp ', ' and Find_in_set (3,recommend_status) ')->select ();
such as children's shoes in the study TP5 encountered do not understand can leave a message below
This article for the author of the original article, reproduced without contact with me, but please specify from http://www.cnblogs.com/kzfbk/p/7728566.html
TP5.0 How to use arrays to query MySQL when using functions