PHPFixing
  • Privacy Policy
  • TOS
  • Ask Question
  • Contact Us
  • Home
  • PHP
  • Programming
  • SQL Injection
  • Web3.0

Saturday, March 19, 2022

[FIXED] Want to display data in desc order

 March 19, 2022     php, yii, yii2-advanced-app     No comments   

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
  • Share This:  
  •  Facebook
  •  Twitter
  •  Stumble
  •  Digg
Newer Post Older Post Home

0 Comments:

Post a Comment

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

Total Pageviews

Featured Post

Why Learn PHP Programming

Why Learn PHP Programming A widely-used open source scripting language PHP is one of the most popular programming languages in the world. It...

Subscribe To

Posts
Atom
Posts
Comments
Atom
Comments

Copyright © PHPFixing