本文整理汇总了PHP中ArticleModel::delete方法的典型用法代码示例。如果您正苦于以下问题:PHP ArticleModel::delete方法的具体用法?PHP ArticleModel::delete怎么用?PHP ArticleModel::delete使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ArticleModel
的用法示例。
在下文中一共展示了ArticleModel::delete方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: delete
public function delete($id)
{
var_dump(__METHOD__);
$config = $this->getConfig();
$model = new ArticleModel($config);
$ret = $model->delete($id);
var_dump($ret);
}
示例2: deleteAction
public function deleteAction()
{
if (!isset($_POST['id_article'])) {
return json_encode(["error" => "article_id missing"]);
}
$article_id = $_POST['id_article'];
$result = ArticleModel::getArticle($this->pdo, $article_id);
if ($result['id_user'] != $_SESSION['id_user']) {
return json_encode(['error' => 'utilisateur']);
}
ArticleModel::delete($this->pdo, $article_id);
return json_encode(["message" => "delete", "article_id" => $article_id]);
}
示例3: indexAction
public function indexAction()
{
if (empty(explode('/', $_SERVER['REQUEST_URI'], 4)[2])) {
header('Location: /');
exit;
} else {
$article_id = explode('/', $_SERVER['REQUEST_URI'], 4)[2];
}
if (ArticleModel::exists($this->pdo, $article_id)) {
if ($_SESSION['auth']['username'] === ArticleModel::getAuthor($this->pdo, $article_id) || $_SESSION['auth']['permissions'] === 'superadmin') {
ArticleModel::delete($this->pdo, $article_id);
header('Location: /');
exit;
}
} else {
header('Location: /404');
exit;
}
}
示例4: del
/**
* 删除文章页面
*/
function del()
{
//序列化主键Id为:1,2,3,...以便批量删除
$del_id = $_POST['del_id'];
$str = implode($del_id, ',');
//实例化
$article = new ArticleModel();
//删除了文章的同时删除掉菜单中的文章,其中type_id为外键
$menu_items = new MenuItemModel();
//删除文章
if ($article->delete($str)) {
//删除文章后删除菜单项中的文章
$where = array('type_id' => array('in', $str), 'type' => 'Article');
$menu_items->where($where)->delete();
$this->assign('jumpUrl', __URL__ . '/index');
$this->success('文章以及相应菜单中文章已删除成功');
} else {
$this->assign('jumpUrl', __URL__ . '/index');
$this->error('文章删除失败');
}
}
示例5: articleDel
public function articleDel()
{
if ($_GET) {
$id = $_GET['id'];
$article = new ArticleModel();
$article_res = $article->delete($id);
if ($article_res) {
$this->success('删除成功!');
} else {
$this->error('删除失败!');
}
}
}
示例6: DeleteArticleAction
public function DeleteArticleAction()
{
$request = Project::getRequest();
$id = (int) $request->getKeyByNumber(0);
if ($id > 0) {
$article_model = new ArticleModel();
$article_model->delete($id);
}
$this->_makeArticleList($data);
$this->_view->AjaxArticleList($data);
$this->_view->ajax();
}