這可以用SQL來完成嗎?我需要根據(jù) $query 是否為false WHERE (u.id_user = ".$userId." OR fu.id_user = ".$userId." OR ff.id_user = ".$userId.")"ELSE來進行 SQL 選擇"$query";這是我必須滿足兩個條件的起點: $validatedSearchData = array( "q"=>strip_tags($_GET["q"]) ); $query= " AND a.tags LIKE ".lib::$db->qstr("%".$validatedSearchData["q"]."%"); $feed = lib::$db->GetAll("SELECT SQL_CALC_FOUND_ROWS a.*, u.name, fu.id_user AS fu_user_id, ff.id_followed_user AS ff_user_id FROM feed AS a LEFT JOIN userfollow AS fu ON a.id_author = fu.id_user LEFT JOIN userfollow AS ff ON a.id_author = ff.id_followed_user INNER JOIN user_profiles AS u ON a.id_author = u.id_user WHERE (u.id_user = ".$userId." OR fu.id_user = ".$userId." OR ff.id_user = ".$userId.")" . $query. " GROUP BY a.id_article ");
1 回答

吃雞游戲
TA貢獻1829條經(jīng)驗 獲得超7個贊
更改此行
$query= " OR a.tags LIKE ".lib::$db->qstr("%".$validatedSearchData["q"]."%");
用 OR 代替 AND
- 1 回答
- 0 關注
- 162 瀏覽
添加回答
舉報
0/150
提交
取消