Fixed multi-word bug in search. Added conditional for no matches.

git-svn-id: http://svn.automattic.com/wordpress/trunk@739 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
emc3 2004-01-08 15:36:45 +00:00
parent f58955f596
commit 3910cf728b
1 changed files with 29 additions and 27 deletions

View File

@ -128,7 +128,7 @@ if (!empty($s)) {
} }
if (!$sentence) { if (!$sentence) {
$s_array = explode(' ',$s); $s_array = explode(' ',$s);
$search .= '((post_title LIKE \''.$n.$s_array[0].$n.'\') OR (post_content LIKE \''.$s_array[0].'\'))'; $search .= '((post_title LIKE \''.$n.$s_array[0].$n.'\') OR (post_content LIKE \''.$n.$s_array[0].$n.'\'))';
for ( $i = 1; $i < count($s_array); $i = $i + 1) { for ( $i = 1; $i < count($s_array); $i = $i + 1) {
$search .= ' AND ((post_title LIKE \''.$n.$s_array[$i].$n.'\') OR (post_content LIKE \''.$n.$s_array[$i].$n.'\'))'; $search .= ' AND ((post_title LIKE \''.$n.$s_array[$i].$n.'\') OR (post_content LIKE \''.$n.$s_array[$i].$n.'\'))';
} }
@ -320,7 +320,8 @@ if ($preview) {
// echo $request; // echo $request;
$posts = $wpdb->get_results($request); $posts = $wpdb->get_results($request);
// No point in doing all this work if we didn't match any posts.
if ($posts) {
// Get the categories for all the posts // Get the categories for all the posts
foreach ($posts as $post) { foreach ($posts as $post) {
$post_id_list[] = $post->ID; $post_id_list[] = $post->ID;
@ -349,4 +350,5 @@ if (1 == count($posts)) {
header('Location: ' . get_permalink($posts[0]->ID)); header('Location: ' . get_permalink($posts[0]->ID));
} }
} }
}
?> ?>