|
@@ -60,24 +60,24 @@ class Article extends Base
|
|
|
if (!preg_match("/^([0-9]{4})\/([0-9]{1,2})$/", $params['yearMonth']) && !preg_match("/^([0-9]{4})-([0-9]{1,2})$/", $params['yearMonth'])) {
|
|
|
throw new HttpException(404, '日期格式不正确');
|
|
|
}
|
|
|
-
|
|
|
$separator = strrpos('/', $params['yearMonth']) ? '/' : '-';
|
|
|
-
|
|
|
+
|
|
|
$year = $month = '';
|
|
|
-
|
|
|
+
|
|
|
if (strnatcasecmp(PHP_VERSION, '7.0.0') >= 0) {
|
|
|
list($year, $month) = explode($separator, $params['yearMonth']);
|
|
|
} else {
|
|
|
list($month, $year) = explode($separator, $params['yearMonth']);
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
if ((int) $month < 1 || (int) $month > 12) {
|
|
|
throw new HttpException(404, '日期格式不正确');
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
$days = month_frist_and_last_day($year, $month);
|
|
|
-
|
|
|
- $where['create_time'] = ['between', [$days['firstday'], $days['lastday']]];
|
|
|
+
|
|
|
+ // $where['create_time'] = ['between', [$days['firstday'], $days['lastday']]];
|
|
|
+ $where[] = ['create_time','between', [$days['firstday'], $days['lastday']]];
|
|
|
}
|
|
|
|
|
|
$limit = empty($params['limit']) ? 20 : (int)$params['limit'];
|
|
@@ -158,9 +158,9 @@ class Article extends Base
|
|
|
return ['prev' => $data_p, 'next' => $data_N];
|
|
|
}
|
|
|
|
|
|
- public function createTimeArchive()
|
|
|
+ public static function createTimeArchive()
|
|
|
{
|
|
|
- $create_times = $this->order('create_time desc')->column('create_time');
|
|
|
+ $create_times = self::order('create_time desc')->column('create_time');
|
|
|
$timeList = [];
|
|
|
foreach ($create_times as $value) {
|
|
|
$yearAndMonth = date("Y-m", $value);
|