M
M
Mark Dio2018-07-17 12:51:07
Yii
Mark Dio, 2018-07-17 12:51:07

YII2 - fetch from database by array value in field other than ID?

I want to get all records from the database by array value. Everything works fine with the id field. With a different field - returns only the first value.

// все ок
$result = ArModel::find()->where([ 'id'=>[1,2,3] ])->all(); 

// только один объект - link
$result = ArModel::find()->where([ 'alias'=>['link', 'link2', 'link3'] ])->all();

How to do it right?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
D
Dmitry Kim, 2018-07-17
@Touranchoks

$result = ArModel::find()->where([ 'alias'=>['link', 'link2', 'link3'] ])->all();

This is analog:
Everything should work. Accordingly, if only one record is returned, perhaps there are no other matches?

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question