Saturday, March 19, 2022

[FIXED] Want to display data in desc order

Issue

I want to display data in desc order.

->where(['listing_section.is_active' => 1])
->innerJoin(Translations::tableName(),'translations.parent_id=listing_section.id')
->andWhere(['translations.parent_tbl' => 'listing'])
->select('listing_section.keywords, listing_section.description, 
listing_section.slug, 
 translations.title,translations.short_text,translations.content');

Solution

You can use the order like this..

->order = 'listing_section.date Desc'; 

date will be the column in your database, Whatever you have there, you can replace it.

you can also use id to show data in DESC or ASC order by id too.

->order = 'listing_section.id Desc'; 

..

->where(['listing_section.is_active' => 1])
->innerJoin(Translations::tableName(),'translations.parent_id=listing_section.id)
->andWhere(['translations.parent_tbl' => 'listing'])
->select('listing_section.keywords, listing_section.description, listing_section.slug, translations.title,translations.short_text,translations.content');
->order = 'listing_section.date Desc'; 

Update:

Simply you try to upgrade the php version. I've your same error with php 5.5, but with php 5.6 everything works fine.



Answered By - Asfandyar Khan

No comments:

Post a Comment

Note: Only a member of this blog may post a comment.