本文整理匯總了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();
}