将数据库存储为逗号分隔的字符串,我想从逗号分隔的字符串中检索数据。
https://code.sololearn.com/wKW8F3caReUY/?ref=app
这段代码是否正常工作bcz它没有向我显示所需的结果
//$userData['city'] = 27 //db中的城市保存为12,33,9,2,1,27,31
//$userData['hobbies'] = 3,24
//hobbies in db have values as 3,24,17,31
// how to i match these records/arrays by my sql db records
$SQL = "SELECT * FROM users_stats WHERE
type = '1'
AND
(
".in_array( $userData['city'],explode(",","'cities'") )."
OR
cities IN('all','pak')
)
AND
(
time = ".$currentTime." OR time = 'all'
)
AND
(
".((array_intersect( explode(",$userData['hobbies']),"'hobbies'")) != null)?1:0)."
)
";