我需要帮助进行评论的搜索查询(这是一个WordPress网站)。PHP/MySQL - 搜索查询
评论中检索该way-如果用户登录:
$comments = $wpdb->get_results($wpdb->prepare("
SELECT * FROM $wpdb->comments WHERE comment_post_ID = %d
AND (comment_approved = '1' OR (user_id = %d AND comment_approved = '0'))
ORDER BY comment_date_gmt", $post->ID, $user_ID));
如果不是:
$comments = $wpdb->get_results($wpdb->prepare("
SELECT * FROM $wpdb->comments WHERE comment_post_ID = %d
AND (comment_approved = '1' OR (comment_author = %s
AND comment_author_email = %s AND comment_approved = '0'))
ORDER BY comment_date_gmt",
$post->ID, wp_specialchars_decode($comment_author,ENT_QUOTES),
$comment_author_email));
,所以我我怎么能过滤包含特定搜索字符串的意见,像$_GET['search_query']
?
这是WP的database structure。我在寻找搜索字符串是comment_content
谢谢,我会尝试。顺便说一句,百分号在$ _GET之前和之后做什么? – Alex 2010-12-14 19:39:12