Just wanted to share my PHP "one-liner" for today. I finally got fed up at my weblog search feature for not searching post titles, so I wrote the code to do it. This line appears in some code that's dynamically building the SQL statement to send to MySQL...
<?php
$search_param = join(' AND ', array_map(create_function('$a', 'return "(Entry_Title LIKE \'%$a%\' OR Entry_Text LIKE \'%$a%\')";'), $search_words));
?>
That's the logic that produces the results for a search if "Phrase search" is unchecked. So you see, each word you search for has to appear in either in the post title or the post text. In other words, it's an AND search not an OR search.
This also works for the degenerate case where you do a phrase search and everything you enter is treated as a string (like a single "search word").
Feel free to post a comment below. Please see my comment policy.
Formatting Rules (No HTML):