Jimothey
Jimothey

Reputation: 2434

CakeDC Search plugin - one search field to search muliple db fields

Within my cakephp 2.3 app I have a one field search at the top of each page. I want this contents of this field to be used to search accross muliple fields. How can I do this?

For example

User searchs for "Error 324" and the search plugin searches the following db fields for that string - article.title, article.error, article.environment and returns any records with the search string within those fields.

I've read the github docs at https://github.com/CakeDC/search and think I need to do soemthing like their OR condition example but am struggling really - could someone point me in the rigt direction?

Thanks

Upvotes: 0

Views: 177

Answers (1)

mark
mark

Reputation: 21743

You did see that there is a readme containing pretty much exactly this scenario?

'username' => array('type' => 'like', 'field' => array('User.username', 'UserInfo.first_name')),

so in your case its just

'field' => array('Article.error', 'Article.title', 'Article.environment', ...)

Upvotes: 1

Related Questions