Thursday, July 30, 2009

HABTM search custom query

Hi,
This is my first post and please forgive me if this question is
already answered. I building a business directory and I encounter a
problem when searching using paginate.
This is my simplified database design
sections ( id, name)
categories_sections(category_id, section_id)
categories (id, name, keywords)
businesses_categories (business_id, category_id);
businesses (id, name, phone, ..., keywords)
I want to do a keyword search, it should search the following fields
businesses.name, businesses.keywords, categories.name and
categories.keywords for match
e.g: Business.name LIKE '%$searchTerm%' OR Business.keywords LIKE '%
$searchTerm%' OR Category.name LIKE '%$searchTerm%' Category.keywords
LIKE '%$searchTerm%'

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "CakePHP" group.
To post to this group, send email to cake-php@googlegroups.com
To unsubscribe from this group, send email to cake-php+unsubscribe@googlegroups.com
For more options, visit this group at http://groups.google.com/group/cake-php?hl=en
-~----------~----~----~----~------~----~------~--~---

No comments: