M
M
Max DangerPro2016-11-22 13:49:41
Yii
Max DangerPro, 2016-11-22 13:49:41

How to work with the like operator?

I'm making a request to the database to fetch data:

$q = Book::find()->where(['like', 'name', $letter])->all();

It turns out here is such a request: How can I do what would be:
SELECT * FROM book WHERE name LIKE '%значение%'
SELECT * FROM book WHERE name LIKE 'значение%'

Answer the question

In order to leave comments, you need to log in

1 answer(s)
I
Ivanq, 2016-11-22
@DangerPro

1. https://www.google.ru/search?q=yii2+like+sql
2. How to write "left" and "right" LIKE in ActiveQuery Yii2?
3. ... 4.
PROFIT
['like', 'name', $letter.'%', false]

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question