本文整理汇总了PHP中ArticleModel::deleteArticle方法的典型用法代码示例。如果您正苦于以下问题:PHP ArticleModel::deleteArticle方法的具体用法?PHP ArticleModel::deleteArticle怎么用?PHP ArticleModel::deleteArticle使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ArticleModel
的用法示例。
在下文中一共展示了ArticleModel::deleteArticle方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: array
if ($article['acc_id'] != $account['acc_id']) {
return Helper::response(false, array(), 'Forbidden, article belongs to different account', 403);
}
$patched = ArticleModel::patchArticle($article['acc_id'], array('art_title' => $app->request->post('art_title', ''), 'art_body' => $app->request->post('art_body', '')));
if (!$patched) {
return Helper::response(false, array(), 'Application error', 500);
}
return Helper::response(true);
});
$app->post('/api-v1.0/article/delete/', function () use($app) {
if (!($account = Helper::checkSecret())) {
return;
}
$artId = $app->request->post('art_id');
if (empty($artId)) {
return Helper::response(false, array(), 'Bad request, art_id required', 400);
}
$article = ArticleModel::getArticle($artId);
if (empty($article)) {
return Helper::response(false, array(), 'Article not found', 404);
}
if ($article['acc_id'] != $account['acc_id']) {
return Helper::response(false, array(), 'Forbidden, article belongs to different account', 403);
}
$deleted = ArticleModel::deleteArticle($article['art_id']);
if (!$deleted) {
return Helper::response(false, array(), 'Application error', 500);
}
FB::log($deleted);
return Helper::response(true);
});
示例2: deleteArticle
public function deleteArticle()
{
$errors = $this->errors;
//实例化Model
$articleModel = new ArticleModel();
$commentModel = new CommentModel();
$collectModel = new CollectModel();
$articleTagModel = new ArticleTagModel();
$articleId = $_GET['articleId'];
$articles = $articleModel->getArticleById($articleId);
$tagIds = trim($articles['tagId'], ',');
$articleTagModel->cutIncByTagIds($tagIds);
$row = $articleModel->deleteArticle($articleId);
//删除文章
$rows = $commentModel->delCommentByArticleId($articleId);
//删除文章评论
$collectModel->deleteCollectByArticleId($articleId);
if ($row) {
$result['code'] = '0';
$result['message'] = $errors['0'];
} else {
$result['code'] = '036';
$result['message'] = $errors['036'];
}
echo json_encode($result);
exit;
}