littlea5h Posted March 5, 2013 Share Posted March 5, 2013 Hey guys, i am trying to implement this piece of code around a full text search but i havent worked with them before. I want that the user doesnt have to enter all of the keyword entered, so they can type half the keyword and it will still display the result. This is what i have so far! public function fetchAllByDescription($description){ $db = Zend_Db_Table::getDefaultAdapter(); $statement_front = "SELECT * FROM p2_parts p INNER JOIN p2_parts_category c ON p.partNumber = c.partNumber WHERE"; $sql = $statement_front." p.description LIKE '%{$description}%' OR c.category LIKE '%{$description}%' LIMIT 200"; $select = $db->query($sql); $results = $select->fetchAll(); if (0 == count($results)) { return; } $products = array(); foreach($results as $r) { if(isset($r['ID'])){ $products[] = $this->find($r['ID']); } } return $products; } Any help would be appreciated. Thanks! Quote Link to comment Share on other sites More sharing options...
Christian F. Posted March 5, 2013 Share Posted March 5, 2013 Seeing as FULLTEXT searches is a MySQL question, and nothing to do with PHP, I've moved this to the correct section. Also, what you have there is not a fulltext search. It's a regular "partial match" search. So before anything, I would recommend you to actually read up on fulltext searches in MySQL. That said, what is your question? I don't see one in your post, and I'm afraid I cannot read your mind. So please remember to give an accurate and full description of your issue, preferably complete with examples of what you want (and what you're getting). That way we will, hopefully, have all of the information we need to help you, straight away, instead of having to waste a lot of time asking you for every single detail (or guess at them). Thank you. Quote Link to comment Share on other sites More sharing options...
littlea5h Posted March 5, 2013 Author Share Posted March 5, 2013 I have tried to alter the code to a fulltext search. As i stated previously, the code i posted earlier was not fulltext as i have not come across the method. I changed the code to this however it still doesnt seem to be working. It just displays the message that shows up to the user that they can not find the keyword. $statement_front = "SELECT * FROM p2_parts p INNER JOIN p2_parts_category c ON p.partNumber = c.partNumber WHERE"; $sql = $statement_front." MATCH (p.manufacturer,p.description) AGAINST ('+{$description} IN BOOLEAN MODE') AND p.description LIKE '%{$description}%' OR c.category LIKE '%{$description}%' LIMIT 200"; $select = $db->query($sql); $results = $select->fetchAll(); Instead of the user wanting to type in the full keyword, i would like it so that they would only enter part of a keyword so it shows something similar. E.g 'key' would display 'keyboard' or 'board' would display 'motherboard, 'keyboard' etc Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.