查询相册更加mysql 查询

接到一个项目项目案例相册是这种结构 

大佬建议

sql 查询  groip 进行时间统计今天
field根据mysql 时间查询进行统计  今天多少条 新增多少条相册   计算天数

$lists = Album::group("from_unixtime(create_time, '%Y-%m-%d')")
->field("from_unixtime(create_time, '%Y-%m-%d') as day,count(*) as count,from_unixtime(create_time, '%Y-%m') as month")
->order("aid desc")
->paginate();

返回数据

    "code": "1",
    "msg": "获取成功",
    "data": [
        {
            "day": "2020-11-27",
            "count": 3,
            "month": "2020-11"
        },
        {
            "day": "2020-11-25",
            "count": 2,
            "month": "2020-11"
        }
    ],
    "time": 1606447964,
    "user": "",
    "page": {
        "total": 2,
        "lastPage": 1,
        "currentPage": 1,
        "listRows": 15
    }

 借鉴 https://blog.csdn.net/kl28978113/article/details/82387432

原文地址:https://www.cnblogs.com/zlf2000/p/14047583.html