MySQL Search Query Library v0.1 |
[eluser]trice22[/eluser]
Hello, I wrote a library which produces MySQL-queries like you need them for a search field, since I needed it for a project and I thought someone might maybe have use for it and/or you could atleast have a look at it (this is the first actual class I wrote - so please have patience). WHAT DOES IT DO? Actually not much: It takes a search string (e.g. from an input field) and forms a MySQL-query for you, using "LIKE". WHY WOULD I NEED IT THEN? Well, it does a few things for you, that might come handy - it: - splits the search-string, but keeps expressions between double-quotes intact - removes a list of too common symbols (except from the expressions) - removes stopwords (words, that are too common) depending on a external stopwords file (so far I've includes stopwords for English, German, French and Finnish) - not the expressions - reduces words to it's stem (using the Porter Stemmer algorithm - so far only for English) - and again leaves the expressions untouched - will allow the usage of the most basic BOOLEANS like "AND or +", "NOT or -" and "OR" - furthermore you have the possibility to set a few options, often used in "advances serach modi" - like "search for ALL words" HOW TO USE IT? Download the zip and extract it into your library folder. Then put into your Model (or Controller): Code: $this->load->library('Emq'); Code: $returnColumns; // What comes back You can also set every option separately: Code: $this->emq->setReturnColumns("returnColumns"); Code: $this->emq->disableStemmer(); // will disable the Porter Stemmer Algorithm WHAT IT DOESN'T DO: - No security features are integrated - CI comes with great security helpers (like xss-cleaning etc.) - just use them before the EMQ. EXAMPLE 1: Code: // The search string EXAMPLE 2: Code: // The search string WHAT I WOULD BE REALLY GRATEFUL FOR: It's the first version, man! Go - find a bug, there gotta be a lot ;D . I don't consider myself to be a programmer nor a very logical thinking person. I write the code I need (if I can) but I usually have to realize later, that there'd be 10.000 better and easier ways. If you've some time, please read through it and if you've any advice about structure and solutions but also coding-style and possibilities to simplify - please let me know. Otherwise, please be my guest and test it, if you have some use for it. THANKS: This class is inspired by the search-class of Stephen Bartholomew -> (http://aspn.activestate.com/ASPN/Cookboo...ipe/125901) and the PHP search engine from roscripts.com -> (http://www.roscripts.com/PHP_search_engine-119.html) It uses the Porter Stemmer algorithm for English by Jon Abernathy <[email protected]> Cheers, trice //EDIT: Apparently I can't submit a query like "% man %" (without the spaces - I guess you know how the MySQL-query would look like anyways. |
Messages In This Thread |
MySQL Search Query Library v0.1 - by El Forum - 08-13-2007, 09:41 AM
MySQL Search Query Library v0.1 - by El Forum - 08-16-2007, 02:03 AM
MySQL Search Query Library v0.1 - by El Forum - 08-16-2007, 02:57 AM
MySQL Search Query Library v0.1 - by El Forum - 08-16-2007, 03:08 AM
MySQL Search Query Library v0.1 - by El Forum - 08-16-2007, 06:15 AM
MySQL Search Query Library v0.1 - by El Forum - 08-16-2007, 06:58 AM
MySQL Search Query Library v0.1 - by El Forum - 01-22-2008, 04:16 PM
MySQL Search Query Library v0.1 - by El Forum - 10-15-2009, 02:47 PM
MySQL Search Query Library v0.1 - by El Forum - 10-16-2009, 01:57 AM
|