修复图文不存在时的异常

This commit is contained in:
Anyon 2020-07-05 21:04:54 +08:00
parent fb118970a4
commit 429bc624af

View File

@ -39,7 +39,8 @@ class MediaService extends Service
{
// 文章主体数据
$data = $this->app->db->name('WechatNews')->where(['id' => $id])->where($where)->find();
list($data['articles'], $articleIds) = [[], explode(',', $data['article_id'])];
if (empty($data)) return [];
[$data['articles'], $articleIds] = [[], explode(',', $data['article_id'])];
if (empty($data['article_id']) || empty($articleIds)) return $data;
// 文章列表组合
$query = $this->app->db->name('WechatNewsArticle')->whereIn('id', $articleIds)->orderField('id', $articleIds);