S
S
Sergey Beloventsev2016-05-18 10:02:10
Yii
Sergey Beloventsev, 2016-05-18 10:02:10

What is the error when forming a request or like?

Here is the actual request

$search = Search::find()->where(['or like', ['name','description'], $query])->limit(30);

You give such an error
strpos() expects parameter 1 to be string, array given
in the documentation it is described like this
or like: Similar to the like operator, only the LIKE clauses will be combined using the OR operator if the second operand is an array.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
V
Vit, 2016-05-18
@fornit1917

"...if the SECOND operand will be represented by an array."
'or like' - operator
['name','description'] - FIRST operand
$query - SECOND operand.
Do you understand?
or like not to search for several columns. Or like in order to make two conditions in one column through OR.
In your case, you should write like this:

Search::find()->orWhere(['like', 'name', $query])->orWhere(['like', 'description', $query])

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question