M
M
mxelgin2018-06-16 00:42:40
Yii
mxelgin, 2018-06-16 00:42:40

How to create a reverse like query in Yii2?

select * from [table] where 'www.site.ru' like [table].[url]
TABLE::find()->where(['like', 'www.site.ru' , 'url']
builds incorrect select
select * from [table] where [www].[site].[ru] like [table].[url]

Answer the question

In order to leave comments, you need to log in

1 answer(s)
M
Maxim Timofeev, 2018-06-18
@webinar

A little embarrassing

reverse like
, what's this? But it probably means this:
$table_name = 'tapki';
$column_name = 'name';
$query_string = 'паралоновые';
$query = new Query();
$result = $query
         ->from($table_name)
         ->andWhere(['like', $column_name, $query_string])
         ->all();
print_r($result);

it? If yes, then all the magic is described in the docs: https://www.yiiframework.com/doc/guide/2.0/ru/db-q... if not, then specify the question

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question