API接口PHP执行文件报错,麻烦知道的朋友看看为什么会报错呢?代码如下:
<?php
/**
* api 示例文件
* 变量介绍
* $return 表示标准返回变量
*/
$return = []; // 返回数据
// 查询内容
$data = \Phpcmf\Service::M()->db->query("select a.id,a.title,a.keywords,a.description,a.updatetime,a.author,a.hits,addon.content from dr_1_article a left join dr_1_article_data_0 addon on addon.id=a.id where a.id=75");
if ($data) {
foreach ($data as $r) {
$return[] = [
'title' => $r['title'],
'keywords' => $r['keywords'],
'description' => $r['description'],
'pubdate' => strftime("%Y-%m-%d %H:%M:%S",$r['updatetime']),
'writer' => $r['author'],
'click' => $r['hits'],
'body' => str_replace('/uploads/',"https://www.yjfglxt.com".'/uploads/', $r['content'])
];
}
echo json_encode(['code' => 1, 'msg'=>'ok', 'data' => $rt]);exit; // 强制返回
}
return $return;报错截图如下:

$data = \Phpcmf\Service::M()->db ->query("select a.id,a.title,a.keywords,a.description,a.updatetime,a.author,a.hits,addon.content from dr_1_article a left join dr_1_article_data_0 addon on addon.id=a.id where a.id=75") ->getResultArray();提示这个是怎么回事呢
<?php /** * api 示例文件 * 变量介绍 * $return 表示标准返回变量 */ $rt = []; // 查询内容 $aid = $_REQUEST['id']; $data = \Phpcmf\Service::M()->db->query("select a.id,a.title,a.keywords,a.description,a.updatetime,a.author,a.hits,addon.content from dr_1_article a left join dr_1_article_data_0 addon on addon.id=a.id where a.id='$aid'"); $rows = $data->getResultArray(); if ($rows) { foreach ($rows as $r) { $rt[] = [ 'title' => $r['title'], 'keywords' => $r['keywords'], 'description' => $r['description'], 'pubdate' => strftime("%Y-%m-%d %H:%M:%S",$r['updatetime']), 'writer' => $r['author'], 'click' => $r['hits'], 'body' => $r['content'], ]; } echo json_encode(['code' => 1, 'msg'=>'ok', 'content' => $rt]);exit; } return $rt;迅睿框架技术-景攸这个的请求url是多少
更新一下
https://www.yjfglxt.com/index.php?s=httpapi&id=1&appid=1&appsecret=PHPCMF701208600AF8E&id=75
重复id了