插件路径/e/extend/api/getInfos.php
前端访问https://www.***.com/e/extend/api/getInfos.php?classid=74&year=2019&month=01
实现效果:输入栏目id、发布年月,最终输出所匹配的信息

<?php
require('../../class/connect.php'); //引入数据库配置文件和公共函数文件
require('../../class/db_sql.php'); //引入数据库操作文件

$link=db_connect(); //连接MYSQL
$empire=new mysqlquery(); //声明数据库操作类
$editor=1; //声明目录层次

$classid = $_REQUEST['classid'];
$year = $_REQUEST['year'];
$month = $_REQUEST['month'];
$sql = $empire->query("select id,title,newstime from {$dbtbpre}ecms_article where classid = $classid and $year = year(FROM_UNIXTIME(newstime,'%Y-%m-%d')) and $month = month(FROM_UNIXTIME(newstime,'%Y-%m-%d')) limit 200");


$data_json = array();

while ($row=$empire->fetch($sql)){
    $data_json[]=array(
        'id'=>$row['id'],
        'title'=>$row['title'],
        'newstime'=>date("Y-m-d",$row['newstime']),
        'data'=>date("d/m/Y",$row['newstime'])
    );
}
echo json_encode($data_json,JSON_UNESCAPED_UNICODE);

db_close(); 
$empire=null; 
?>
©本文为原创文章,著作权归博主所有,转载请联系博主获得授权

发表评论