L
L
Light7772015-01-02 16:13:55
Yii
Light777, 2015-01-02 16:13:55

How to do a search in Yii2?

There is a normal input for entering text to search
How can I search by title?
type Select * from posts where title like '% what the user submitted%'
Looked on the Internet there everything using gridview
I would like a simple search, the user enters the title and the search returns all posts where the title contains this fragment

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
Anton Natarov, 2015-01-02
@HanDroid

So, what's the difficulty? make a form with input write validation to it.
you have a request for QB, you wrote it yourself. You make a request, the output can be done through Ajax if the database is small.
I only recommend that you do LIKE LOWER('% what the user sent%').
It is likely that your project can stand on different databases, and for example PostgreSQL has a different analogue of LIKE, it searches case-insensitively for an analogy to a muscle case-insensitively, it will be like this ILIKE LOWER ('% what the user sent%')

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question