本文整理汇总了PHP中ArticleModel::addArticle方法的典型用法代码示例。如果您正苦于以下问题:PHP ArticleModel::addArticle方法的具体用法?PHP ArticleModel::addArticle怎么用?PHP ArticleModel::addArticle使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ArticleModel
的用法示例。
在下文中一共展示了ArticleModel::addArticle方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: publishAction
/**
* 发布
* @return bool
*/
public function publishAction()
{
if (!$this->getRequest()->isPost()) {
$this->responseJson(401, '请求方式不正确');
}
//$username = $this->getRequest()->getParam('username','');
//$password = $this->getRequest()->getParam('password','');
$title = $_POST['title'];
$content = $_POST['content'];
if (empty($title) && empty($content)) {
$this->responseJson(401, '文章title或内容不能为空');
}
$article = new ArticleModel();
$ret = $article->addArticle($title, $content);
if ($ret[0]) {
$this->responseJson(200, $ret[1]);
} else {
$this->responseJson(401, $ret[1]);
}
return false;
}
示例2: array
return Helper::response(false, array(), 'Application error', 500);
}
return Helper::response(true, $articles);
});
$app->get('/api-v1.0/article/get/:id/', function ($id) use($app) {
$article = ArticleModel::getArticle($id);
if (empty($article)) {
return Helper::response(false, array(), 'Article not found', 404);
}
return Helper::response(true, $article);
});
$app->post('/api-v1.0/article/add/', function () use($app) {
if (!($account = Helper::checkSecret())) {
return;
}
$artId = ArticleModel::addArticle(array('acc_id' => $account['acc_id'], 'art_title' => $app->request->post('art_title', ''), 'art_body' => $app->request->post('art_body', '')));
if (empty($artId)) {
return Helper::response(false, array(), 'Application error', 500);
}
return Helper::response(true, array('art_id' => $artId));
});
$app->post('/api-v1.0/article/patch/', 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)) {
示例3: addArticleSubmit
public function addArticleSubmit()
{
$errors = $this->errors;
$pdata = $_POST;
//echo "<pre>";var_dump($pdata['content']);echo "</pre>";exit;
if (!$pdata['title']) {
$result['code'] = '038';
$result['message'] = $errors['038'];
} elseif (!$pdata['typeId']) {
$result['code'] = '039';
$result['message'] = $errors['039'];
} elseif (!$pdata['content']) {
$result['code'] = '030';
$result['message'] = $errors['030'];
} else {
//实例化Model
$articleModel = new ArticleModel();
if (isset($pdata['content'])) {
$start = strpos($pdata['content'], '<img');
$end = strpos($pdata['content'], '/>', $start);
$img = substr($pdata['content'], $start, $end - $start + 2);
$preg = '/src="(.*)"[\\s\\n]*\\/>/';
preg_match($preg, $img, $matche);
$pdata['picture'] = $matche[1];
}
$articleTagModel = new ArticleTagModel();
if (isset($pdata['tagId']) && $pdata['tagId']) {
$pdata['tagId'] = array_unique($pdata['tagId']);
//数组去重
$tagIds = implode(',', $pdata['tagId']);
$articleTagModel->setIncByTagIds($tagIds);
$pdata['tagId'] = ',' . implode(',', $pdata['tagId']) . ',';
}
$pdata['adminId'] = $_SESSION['admin']['adminId'];
$results = $articleModel->addArticle($pdata);
if ($results) {
$result['code'] = '0';
$result['message'] = $errors['0'];
} else {
$result['code'] = '034';
$result['message'] = $errors['034'];
}
}
echo json_encode($result);
exit;
}