I asked this question about a year ago on another site but never got the answers I was looking for. And I’ve been wondering about it ever since.
I’d like to impliment some search functions similar to Google’s (inurl:foo, site:bar.com)
So if you entered a normal query, with none of these functions included, it would search one column.
However if you included a function (func:foo bar) it would search column 1 for foo and column 2 for bar.
What’s a good solution for this in PHP and MySQL. Also, multiple functions (func1:foo func2:bar query) would be good too.
I dont think there is a direct way to do that, but you can write a script.
Your script first parse the search query and find special occurences, something like this:
Then you have special requests for your search, say your user asked for
user:marvin tag:php comment:preg. Then you know with above regular expression that your user wants to see the comments ormarvintagged asphpand includes the termpregand you can build your sql statement accordingly.