Re: Search-Engine for MySQL an Weblike Requests!

From: Date: Wed, 07 Jun 2000 22:12:08 +0000
Subject: Re: Search-Engine for MySQL an Weblike Requests!
References: 1 2  Groups: php.general 
Request: Send a blank email to php-general+get-1255@lists.php.net to get a copy of this message
On Wed, Jun 07, 2000 at 09:37:56PM +0100, j d robinson wrote: > <snip> > > Does anyone know, where I can find this function? Else I have to code it > > myself, but I'm to lazy for it! ;) > </snip> > > Now, I'm new here and I am just a lurker untill I know what goes on. But I'm > sure this sort of post is never going to, and should not get a reply > > Regards > Dale Robinson > Mr. Robinson, Forgive my posting this, but I wouldn't have written it if it weren't for Mr. Kuhl's posting and I really needed it myself. Maybe someone else can use it also... Ryan function search_query ($str, $tablename, $searchfields, $resultfields, $after_where="") { // ryan adams 6/6/00 // $searchfields are space separated: "field1 field2 field3" // $resultfields are comma separated: "field1, field2, field3" // $str is in the form "-nope +yep +thistoo -notthis" // note: each entry must have a + or - before it or it is ignored $a_fields = explode (" ", $searchfields); $a = explode (" ", $str); while (list($k, $v) = each ($a)) { if ($v[0] == "-") { $a_query[] = "NOT LIKE \"%".substr ($v, 1)."%\""; } elseif ($v[0] == "+") { $a_query[] = "LIKE \"%".substr ($v, 1)."%\""; } } for ($i=0; $i<@count($a_fields); $i++) { $naq = ""; for ($j=0; $j<count($a_query); $j++) { $naq[]="$a_fields[$i] $a_query[$j]"; } $b_query[] = "(".implode (" AND ", $naq).")"; } $q = implode (" OR ", $b_query); $q1 = "select $resultfields from $tablename where ($q) "; if ($after_where) $q1 .= $after_where; return $q1; } > ----- Original Message ----- > From: "Oliver Kuhl" <O.Kuhl@gmx.de> > To: <php-general@lists.php.net> > Sent: Tuesday, June 06, 2000 12:19 PM > Subject: [PHP-GENERAL] Search-Engine for MySQL an Weblike Requests! > > > > Hi! > > > > I'm looking for a class or function, which provides the construction of a > > MySQLQuery-String directly from an enterd searchstring like:'+"the rock" > > +movie -geography' > > Additional, the function should allow to enter the tablename, the fields > (in > > which I want to search) and the fields I want to receive. The function > > should return something like that: > > > > 'SELECT id, description FROM tablemovie WHERE ((name LIKE "%the > > rock%")OR(content LIKE "%the rock%"))AND ((name LIKE > > "%movie%")OR(content > > LIKE "%movie%"))AND NOT((name LIKE "%geography%")OR(content LIKE > > "%geography%")) > > > > Does anyone know, where I can find this function? Else I have to code it > > myself, but I'm to lazy for it! ;) > > > > Regards, > > Oliver. > > > > > > -- > > PHP General Mailing List (http://www.php.net/) > > To unsubscribe, e-mail: php-general-unsubscribe@lists.php.net > > For additional commands, e-mail: php-general-help@lists.php.net > > To contact the list administrators, e-mail: php-list-admin@lists.php.net > > > > > > > > > > -- > PHP General Mailing List (http://www.php.net/) > To unsubscribe, e-mail: php-general-unsubscribe@lists.php.net > For additional commands, e-mail: php-general-help@lists.php.net > To contact the list administrators, e-mail: php-list-admin@lists.php.net ---end quoted text---

« previous php.general (#1255) next »