rasny92
(Saminiemi)
1
Hi.
I stopped thinking…
I would like to display in GridView data from the table Announcement where id is related with id_ann
Tables:
Announcement
id | title | description | price
Favourite
id | id_ann | user_id
How to do it?
I tried this:
$query = Announcement::find()->joinWith('favourite')->where(['=', 'favourite.id_ann', $this->id]);
But I getting: No results…
rasny92
(Saminiemi)
3
It’s standard code
<?= GridView::widget([
'dataProvider' => $dataProvider,
'filterModel' => $searchModel,
'columns' => [
['class' => 'yii\grid\SerialColumn'],
'id',
'title',
'description',
'price'
]);?>
Probably there are not records that satisfy the condition
['=', 'favourite.id_ann', $this->id]
Who is $this->id ?
rasny92
(Saminiemi)
5
It works when I use this code:
$query = Announcement::find()->innerJoinWith('favourite')->andFilterWhere(['>', 'favourite.id_ann', 'id']);
but when I change > to = it shows "No results…"