A
A
Ainur1232018-04-17 16:05:30
Yii
Ainur123, 2018-04-17 16:05:30

How to display not all database records in Yii2?

With the help of gii (Yii2) I made a model and a form for changing, viewing, deleting records from the database. So, it outputs all entries, how do I make it output entries if the field is author_id=Yii::$app->user->identity['id'] ?
5ad5f0c9a84f1298916431.png

Answer the question

In order to leave comments, you need to log in

1 answer(s)
M
Maxim Fedorov, 2018-04-17
@Ainur123

add a condition to the selection, ala:

$query = Products::find()->where([
    'author_id' => Yii::$app->user->identity['id'] 
])

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question