本文整理汇总了PHP中ArticleModel::create方法的典型用法代码示例。如果您正苦于以下问题:PHP ArticleModel::create方法的具体用法?PHP ArticleModel::create怎么用?PHP ArticleModel::create使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ArticleModel
的用法示例。
在下文中一共展示了ArticleModel::create方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: indexAction
public function indexAction()
{
header('content-type: application/json');
header('Access-Control-Allow-Origin: *');
header('Access-Control-Allow-Methods: POST');
$valid = true;
$errors = [];
$title = trim(ucfirst(strtolower(htmlentities($_POST['title']))));
$content = trim(htmlentities($_POST['content']));
if (!isset($title) || empty($title)) {
$errors['title'] = '<span class="errors">Non saisi</span>';
$valid = false;
} elseif (strlen($title) > 51) {
$errors['title'] = '<span class="errors">Trop long</span>';
$valid = false;
}
if (!isset($content) || empty($content)) {
$errors['content'] = '<span class="errors">Non saisi</span>';
$valid = false;
}
$errors['valid'] = $valid;
if ($valid) {
$errors['create'] = ArticleModel::create($this->pdo, $title, $content, $_SESSION['auth']['username']);
}
echo json_encode($errors);
}
示例2: createAction
public function createAction()
{
if (empty($_POST['article_title']) || empty($_POST['article_content'])) {
return json_encode(["error" => "title or content missing"]);
}
$article_title = $_POST['article_title'];
$article_content = $_POST['article_content'];
$article_id = ArticleModel::create($this->pdo, $article_content, $article_title);
return json_encode(["message" => "done", "article_id" => $article_id, "article_title" => $article_title, "article_content" => $article_content, "auteur" => $_SESSION['user']]);
}
示例3: update
public function update()
{
if (!IS_POST) {
$this->message2('非法操作!', __APP__ . '/Admin');
}
$id = I('id', NULL);
if (!empty($id)) {
$article = new ArticleModel();
if ($data = $article->create()) {
if (false !== $article->save()) {
$this->message('编辑成功', __URL__ . '/index');
} else {
$this->message('编辑失败:' . $article->getError(), __URL__ . '/index');
}
} else {
$this->message('编辑失败:' . $article->getError(), __URL__ . '/index');
}
} else {
$this->message('请选择编辑对象', __URL__ . '/index');
}
}
示例4: update
/**
* 文章编辑更新页面
*/
function update()
{
$article = new ArticleModel();
if (!!($data = $article->create())) {
if (!empty($data['id'])) {
if (false !== $article->save()) {
$this->assign('jumpUrl', __URL__ . '/index');
$this->success('更新成功');
} else {
$this->error('更新失败:' . $article->getDbError());
}
} else {
$this->error('请选择编辑用户');
}
} else {
$this->error('更新失败:( ' . $article->getError() . ' )');
}
}
示例5: articleNew
public function articleNew()
{
if ($_POST) {
$article = new ArticleModel();
$data = $article->create();
$article_title = $_POST['article_title'];
$article_type_id = $_POST['article_type_id'];
$article_keywords = $_POST['article_keywords'];
$article_intro = $_POST['article_intro'];
$article_content = trim($_POST['article_content']);
$sql = "INSERT INTO `article` (`article_title` ,`article_type_id` ,`article_keywords` ,`article_intro` ,`article_content` )\r\n\t\t\tVALUES ('" . mysql_escape_string($article_title) . "', '{$article_type_id}', '" . mysql_escape_string($article_keywords) . "','" . mysql_escape_string($article_intro) . "','{$article_content}')";
echo $sql;
if ($article->execute($sql)) {
$this->redirect('articleList');
} else {
$this->error("添加失败!");
}
}
$article_type = new Article_typeModel();
$article_type_res = $article_type->findAll();
// var_dump($article_type_res);
$this->assign('article_type_res', $article_type_res);
$this->display();
}