thinkphp querying MySQL database data time sorting problem

Source: Internet
Author: User
Now there are three states, the first one has expired, the second does not expire, the third is the time to determine the effect that I want now is the non-expiry time before, to determine the time in the middle, the expiration time after, the sort statement should be how to write?
$list = $activity->where (' is_check=1 ')->order (' actdate desc ')->limit ($Page->firstrow. ', '. $Page listRows)->select ();

Now the sort is only according to the time Desc sort, because the related pagination, so not very will write, please help. Thank you.


Reply to discussion (solution)

What is your status field? The field of assumed state is Zhuangtai
Then the SQL statement inside order is written as ORDER by Zhuangtai Desc,actdate Desc will be sorted by state and then (in the same state) sorted by time

  • Contact Us

    The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

    If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

    A Free Trial That Lets You Build Big!

    Start building with 50+ products and up to 12 months usage for Elastic Compute Service

    • Sales Support

      1 on 1 presale consultation

    • After-Sales Support

      24/7 Technical Support 6 Free Tickets per Quarter Faster Response

    • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.