Jump to content


Photo

Use of Wildcards in dbQuery in SearchForm


  • Please log in to reply
2 replies to this topic

#1 Christiane

Christiane

    Etomite Forum Fan

  • Member
  • Pip
  • 124 posts

Posted 25 September 2009 - 06:25 PM

I want to modify SearchForm in that way that I've four radioButtons to put in some Wildcards to decide to search for:

1. $search - exact match
2. %$search - contains $search at the end
3. $search% - contains $search at the beginning
4. %$search% - contains $search anywhere

If i look at the code of SearchForm the crucial codes are:

a. $sql = "SELECT id, pagetitle, parent, description FROM $tbl WHERE ($tbl.content LIKE '%".$search[0]."%'";
b. $sql .= " AND $tbl.content like '%$search[$x]%'";
Source: http://www.etomite.c...rchform__st__30

where in my comprehension % is set to case four (%$search%)so that string has to contain $search anywhere.
But if i delete one or both % e.g. to get the exact match i get no results.
Where is the error in my reasoning?

Edited by Christiane, 25 September 2009 - 06:26 PM.


#2 Ralph

Ralph

    Loves Etomite Forums!

  • Admin
  • 6,539 posts

Posted 26 September 2009 - 01:51 PM

I have several alternate LIKE based search snippets kicking around somewhere... I'll see if I can dig them out when I get a chance to look for them...

#3 Christiane

Christiane

    Etomite Forum Fan

  • Member
  • Pip
  • 124 posts

Posted 26 September 2009 - 03:09 PM

I have several alternate LIKE based search snippets kicking around somewhere... I'll see if I can dig them out when I get a chance to look for them...



At a first step i change to WHERE MATCH () AGAINST () in Boolean mode. But it would be nice also to include the above named functions.




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users