thinkphp5+mysql 分組排序,並且按照時間倒序排列

<?php        

         //mysql 5.7及以上版本,需要加入limit限制,先算出總的記錄條數
		$countz = Db::table("order_detail")->where($odmap)->count();


		$cod = Db::table("order_detail")
		->field("userid,created")
		->order("created desc")	
		->limit($countz)	
		->buildSql();

		$od = Db::table("$cod od")
		->group("od.userid")
		->order("od.created desc")
		->select();

 

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章