本文整理匯總了PHP中ArticleModel::where方法的典型用法代碼示例。如果您正苦於以下問題:PHP ArticleModel::where方法的具體用法?PHP ArticleModel::where怎麽用?PHP ArticleModel::where使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類ArticleModel
的用法示例。
在下文中一共展示了ArticleModel::where方法的8個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: del
public function del()
{
$id = I('id', NULL);
if (!empty($id)) {
if (is_array($id)) {
$where = 'id in (' . implode(',', $id) . ')';
} else {
$where = 'id = ' . $id;
}
$article = new ArticleModel();
if (false !== $article->where($where)->delete()) {
$this->message('刪除成功', __URL__ . '/index');
} else {
$this->message('刪除失敗:' . $article->getError(), __URL__ . '/index');
}
} else {
$this->message('請選擇刪除對象', __URL__ . '/index');
}
}
示例2: edit_tj
/**
* 編輯文章推薦
*/
public function edit_tj()
{
$id = $_GET['id'];
$is_tj = $_GET['is_tj'];
if ($is_tj == 1) {
$is_tj = 0;
} else {
$is_tj = 1;
}
$M = new ArticleModel();
$data = array("is_tj" => $is_tj);
$rs = $M->where("id=" . $id)->save($data);
if ($rs) {
$this->success("操作成功!");
} else {
$this->error("操作失敗!");
}
}
示例3: del
/**
* 刪除數據
*/
function del()
{
//implode序列化主鍵Id為:1,2,3,...以便批量刪除
$del_id = $_POST['del_id'];
$catid = implode($del_id, ',');
//實例化模型
$category = new CategoryModel();
$article = new ArticleModel();
$menu_items = new MenuItemModel();
//刪除分類
if ($category->delete($catid)) {
//刪除文章的where語句
$where = array('catid' => array('in', $catid));
//刪除文章
$article->where($where)->delete();
//刪除類別後刪除菜單項中的類別
$menu_where = array('type_id' => array('in', $catid), 'type' => 'Category');
$menu_items->where($menu_where)->delete();
$this->assign('jumpUrl', __URL__ . '/index');
$this->success('分類,下屬文章以及相應的菜單項刪除成功~~~~');
} else {
$this->assign('jumpUrl', __URL__ . '/index');
$this->error('分類刪除失敗!' . $category->getError());
}
}
示例4: ArticleModel
/**
* 生成RSS
*/
function generate_rss()
{
//得到每一天所有的最新文章
$article = new ArticleModel();
$where = array('created' => array('gt', date("Y-m-d")));
$list = $article->where($where)->select();
//定義生成RSS的字符串
$str = '';
$str .= '<?xml version="1.0" encoding="utf-8"?>
<rss version="2.0">
<channel>
<title>' . C('SITENAME') . '</title>
<link>' . C('SITEURL') . '</link>
<keywords>' . C('SITE_KEYWORDS') . '</keywords>
<description>' . C('SITE_DESCRIPTION') . '</description>';
foreach ($list as $art) {
$str .= '
<item>
<title>' . $art['title'] . '</title>
<link>' . C('SITEURL') . '/Article/view/id/' . $art['id'] . '</link>
<description>' . $art['description'] . '</description>
<pubDate>' . $art['created'] . '</pubDate>
</item>';
}
$str .= '
</channel>
</rss>
';
//將數據寫入文件
$handle = fopen('rss.xml', 'w');
if (fwrite($handle, $str) !== false) {
$this->assign("jumpUrl", "__APP__/Manage/index");
$this->success('RSS文件寫入成功,文件路徑為根目錄');
} else {
$this->assign("jumpUrl", "__APP__/Manage/index");
$this->error('RSS文件寫入失敗,請聯係管理員');
}
fclose($handle);
}
示例5: articleList
public function articleList()
{
if (!empty($_GET['t'])) {
$condition['article_type_id'] = $_GET['t'];
}
$article = new ArticleModel();
$article_res = $article->where($condition)->relation(true)->findAll();
$this->assign('article_res', $article_res);
$this->display();
}
示例6: getModelFromSlug
public function getModelFromSlug($slug)
{
$cache = new Cache();
$cache->setLocalPath($slug . '_article');
$cache->load();
if ($cache->isValid()) {
$model = new ModelWrapper($cache->getData());
} else {
$model = ArticleModel::where('slug', '=', $slug)->with('contents')->first();
if (empty($model)) {
throw new HttpException(404);
}
$cache->setData($model);
$cache->save();
}
return $model;
}
示例7: del
/**
* 單元刪除頁麵
*/
function del()
{
//因為刪除一個單元,就要刪除其手下的分類類別,而刪除分類類別後就要刪除該類別下麵的文章
//所有必須使用關聯操作來執行
//序列化主鍵Id為:1,2,3,...以便批量刪除
$del_id = $_POST['del_id'];
$section_id = implode($del_id, ',');
//實例化
$section = new SectionModel();
$category = new CategoryModel();
$article = new ArticleModel();
$menu_items = new MenuItemModel();
//如果單元刪除成功
if ($section->delete($section_id)) {
//刪除下屬分類以及分類下屬文章
$where = array('sectionid' => array('in', $section_id));
//刪除分類
$category->where($where)->delete();
//刪除文章
$article->where($where)->delete();
//刪除單元後刪除菜單項中的單元
$menu_where = array('type_id' => array('in', $section_id), 'type' => 'Section');
$menu_items->where($menu_where)->delete();
$this->assign('jumpUrl', __URL__ . '/index');
$this->success('單元,菜單項以及所有相關文章類別已刪除~~~~');
} else {
$this->assign('jumpUrl', __URL__ . '/index');
$this->error('刪除失敗~~~~' . $category->getError());
}
}
示例8: head
/**
* 公用頭部 方法
*/
function head()
{
//讀取前台配置文件,因為該文件沒有包含進配置文件,使用快速方法 F
$config = F('front_info.inc', '', './Config/');
$this->assign('config', $config);
//獲得滾動文章的列表
$Articles = new ArticleModel();
$art_where = array("published" => array('eq', 1));
$list = $Articles->where($art_where)->order("id desc")->limit($config['rollnum'])->select();
$this->assign('roll_arts', $list);
}