Re: AND OR NOT

From: Date: Mon, 05 Sep 2005 13:50:00 +0000
Subject: Re: AND OR NOT
References: 1 2  Groups: php.general 
Request: Send a blank email to php-general+get-221863@lists.php.net to get a copy of this message
John Taylor-Johnston wrote: > Any ideas? Post kind of lost in there since Saturday. Is str_replace the > best choice for case sensitive and for swapping " AND "? > >> <input TYPE="text" NAME="searchenquiry" VALUE="" >> size=30> >> >> Any suggestion on how to swap AND OR NOT for mysql fulltext syntax in >> $searchenquiry? >> A simple parse for " AND " and then str_replace? Is str_replace >> appropriate for case? > > John I think you have a slightly more complex situation than just replacing text between what I assume is a LIKE or multiple WHERE situation and a fulltext search. Perhaps if you can give an idea of the type of string you are likely to get in $searchenquiry, and to what you wish to convert it, we might be better placed to give advice. I can envisage that you might get 'bananas NOT pears AND apples' in the variable; I guess you would currently manipulate that to a query such as "WHERE x = 'bananas' AND x <> 'pears' AND x = 'apples'" (OK that's not a good example) but if you were to feed that to a fulltext search you might want WHERE MATCH (x) AGAINST ('+bananas -pears -apples' IN BOOLEAN MODE) or maybe something else depending on the version of Mysql and exactly what you are trying to do with your fulltext search. Cheers -- David Robley Why do cats have canine teeth?

« previous php.general (#221863) next »