I do not get it running.
in my searchManager() function in my UserTable I put in there
$this->getBehavior('Search')->searchManager()
->value('user_id')
->add('email', 'Search.Like', [
'before' => true,
'after' => true,
'fieldMode' => 'OR',
'comparison' => 'LIKE',
'wildcardAny' => '*',
'wildcardOne' => '?',
'fields' => ['email'],
])
This will find user by email. But when I add there a second field like role_id
$this->getBehavior('Search')->searchManager()
->value('user_id')
->add('email', 'Search.Like', [
'before' => true,
'after' => true,
'fieldMode' => 'OR',
'comparison' => 'LIKE',
'wildcardAny' => '*',
'wildcardOne' => '?',
'fields' => ['email', 'role_id'],
])
Then I get an error because this tries to search the email also in the field role_id, which is a number.
and when I add another field
$this->getBehavior('Search')->searchManager()
->value('user_id')
->add('email', 'Search.Like', [
'before' => true,
'after' => true,
'fieldMode' => 'OR',
'comparison' => 'LIKE',
'wildcardAny' => '*',
'wildcardOne' => '?',
'fields' => ['email'],
])
->add('role_id', 'Search.Like', [
'before' => false,
'after' => false,
'fieldMode' => 'AND',
'comparison' => 'LIKE',
'wildcardAny' => '*',
'wildcardOne' => '?',
'fields' => ['role'],
]);
The role_id will be ignored on the search query.
What I found in docu was that I can use the add() methode several times. But it does not work in my example.
In additional, I do not know, what else can I use instead of like search. I want to find where role_id = 2
Sorry but when I read docu, I have a lot of questions