本文整理汇总了PHP中Article::where方法的典型用法代码示例。如果您正苦于以下问题:PHP Article::where方法的具体用法?PHP Article::where怎么用?PHP Article::where使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Article
的用法示例。
在下文中一共展示了Article::where方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: detail
function detail($title_none = NULL)
{
$cat_news_url = $this->uri->segment(1);
$cat_news = new Newscatalogue();
$cat_news->where(array('name_none' => $cat_news_url))->get();
if (!$cat_news->exists()) {
show_404();
}
$dis['cat_news'] = $cat_news;
$cat = $this->uri->segment(2);
$category = new Newscatalogue();
$category->where(array('name_none' => $cat, 'parentcat_id' => $cat_news->id))->get();
if (!$category->exists()) {
show_404();
}
$dis['category'] = $category;
$title_none = geturlfromuri($this->uri->segment(3));
$news = new Article();
$news->where(array('title_none' => $title_none, 'newscatalogue_id' => $category->id));
$news->get();
if (!$news->exists()) {
redirect(base_url() . $this->uri->segment(1, '') . '/' . $this->uri->segment(2, ''));
die;
}
$dis['news'] = $news;
$tag = $news->tag;
$dis['tag'] = explode(',', $tag);
$news->view_count = $news->view_count + 1;
$news->save();
//related news
$related_news = new Article();
$related_news->where('recycle', 0);
$related_news->where('newscatalogue_id', $news->newscatalogue_id);
$related_news->where("id !=", $news->id);
$related_news->order_by('created', 'DESC');
$related_news->get_paged(0, 15, TRUE);
$dis['related_news'] = $related_news;
$arrayCateNewsId = array();
foreach ($this->guideCate as $row) {
$arrayCateNewsId[] = $row->id;
}
$arrayCateNewsId = array();
foreach ($this->guideCate as $row) {
$arrayCateNewsId[] = $row->id;
}
// get news view most
$newViewMost = new Article();
$newViewMost->where('recycle', 0);
$newViewMost->where_in('newscatalogue_id', $arrayCateNewsId);
$newViewMost->order_by('view_count', 'desc');
$newViewMost->get(5);
$dis['newViewMost'] = $newViewMost;
// get news view most
$newView = new Article();
$newView->where('recycle', 0);
$newView->where_in('newscatalogue_id', $arrayCateNewsId);
$newView->order_by('created', 'desc');
$newView->get(5);
$dis['newView'] = $newView;
$this->page_title = $news->{'title_vietnamese'} . ' | SotayNhadat.vn';
$this->page_description = $news->short_vietnamese;
$this->page_keyword = $news->tag;
$this->url = base_url() . substr($this->uri->uri_string, 1, strlen($this->uri->uri_string));
$this->isRobotFollow = 1;
$dis['base_url'] = base_url();
$dis['view'] = 'front/guides/news_de';
$this->viewfront($dis);
}
示例2: detail
function detail($title_none = NULL)
{
$title_none = $this->uri->segment(3);
$arrTitle = explode('.', $title_none);
if ($arrTitle[1] == '' || $arrTitle[1] != 'html') {
redirect('');
}
$title_none = $arrTitle[0];
$news = new Article();
$news->where('title_none', $title_none);
$news->get();
//print_r($this->db->last_query());exit();
if (!$news->exists()) {
show_404();
}
$dis['news'] = $news;
//related news
$related_news = new Article();
$related_news->where('recycle', 0);
$related_news->where('newscatalogue_id', $news->newscatalogue_id);
$related_news->where("id !=", $news->id);
$related_news->order_by('created', 'DESC');
$related_news->get_paged(0, 10, TRUE);
$dis['related_news'] = $related_news;
$category = new Newscatalogue($news->newscatalogue_id);
$dis['category'] = $category;
$this->page_title = $news->{'title_vietnamese'};
$this->page_description = $news->short_vietnamese;
$this->page_keyword = $news->tag;
$dis['base_url'] = base_url();
$dis['link'] = base_url() . $_SERVER['REQUEST_URI'];
$dis['view'] = 'front/services/news_de';
$this->viewfront($dis);
}
示例3: detail
function detail($url)
{
$urlcat = $this->uri->segment(1);
$category = new Newscatalogue();
$category->where(array('recycle' => 0, 'name_none' => $urlcat))->get();
if (!$category->exists()) {
show_404();
}
$dis['category'] = $category;
$url = geturlfromuri($this->uri->segment(2));
$news = new Article();
$news->where(array('title_none' => $url, 'recycle' => 0));
$news->get();
if (!$news->exists()) {
show_404();
}
$dis['news'] = $news;
$this->page_title = $news->title_vietnamese;
$this->page_description = $news->short_vietnamese;
$this->page_keyword = $news->tag;
//related news
$related_news = new Article();
$related_news->where('recycle', 0);
$related_news->where('newscatalogue_id', $news->newscatalogue_id);
$related_news->where("id !=", $news->id);
$related_news->order_by('created', 'DESC');
$related_news->get_paged(0, 10, TRUE);
$dis['related_news'] = $related_news;
$dis['base_url'] = base_url();
$dis['view'] = 'front/newsother/news_de';
$this->viewfront($dis);
}
示例4: getNewsByCategory
function getNewsByCategory($categoryID)
{
$CI =& get_instance();
$cat_news = new Article();
$cat_news->where(array('recycle' => 0));
$cat_news->where('newscatalogue_id', $categoryID);
$cat_news->order_by('created', 'desc');
$cat_news->get(4);
return $cat_news;
}
示例5: show
/**
* Show article
* @param string $slug Article abbreviated name
* @return response
*/
public function show($slug)
{
$article = Article::where('slug', $slug)->where('post_status', 'open')->first();
is_null($article) and App::abort(404);
$categories = Category::orderBy('sort_order')->get();
return View::make('article.show')->with(compact('article', 'categories'));
}
示例6: postBlogComment
/**
* 提交评论
* @param string $slug 文章缩略名
* @return response
*/
public function postBlogComment($slug)
{
// 获取评论内容
$content = e(Input::get('content'));
// 字数检查
if (mb_strlen($content) < 3) {
return Redirect::back()->withInput()->withErrors($this->messages->add('content', '评论不得少于3个字符。'));
}
// 查找对应文章
$article = Article::where('slug', $slug)->first();
// 创建文章评论
$comment = new Comment();
$comment->content = $content;
$comment->article_id = $article->id;
$comment->user_id = Auth::user()->id;
if ($comment->save()) {
// 创建成功
// 更新评论数
$article->comments_count = $article->comments->count();
$article->save();
// 返回成功信息
return Redirect::back()->with('success', '评论成功。');
} else {
// 创建失败
return Redirect::back()->withInput()->with('error', '评论失败。');
}
}
示例7: getIndex
public function getIndex($page = 1)
{
$newses = \Article::where('status', '=', '1')->where('category', '=', '3')->where('open_at', '<=', date('Y-m-d'))->orderBy('sort', 'desc')->orderBy('created_at', 'desc')->skip(0)->take(10)->get(array('id', 'title', 'open_at'));
if ($newses === null) {
$newses = array();
}
return \View::make('aesthetics.index.index', array('newses' => &$newses));
}
示例8: boot
public static function boot()
{
parent::boot();
//删除时先删除相关文档、单页
self::deleting(function (User $user) {
Article::where('uid', '=', $user->id)->delete();
Page::where('uid', '=', $user->id)->delete();
});
}
示例9: get_index
public function get_index($authorname)
{
$user = User::where('username', '=', $authorname)->first();
//get the article limit size
$articles = Article::where('author_id', '=', $user->id)->paginate(Setting::find(2)->value);
$dbquery = $articles;
$articles = cmsHelper::bakeArticleForViewers($articles->results);
return View::make('visitor.index', array("articles" => $articles, 'dbquery' => $dbquery, 'message' => 'Showing all articles by ' . $user->displayname));
}
示例10: searcharticles
public function searcharticles(Request $request)
{
if ($request->ajax()) {
if ($request->has('articlestat')) {
$searcharticles = Article::where('stat', '=', $request->input('articlestat'))->get();
$scontent = view(athr . '.searcharticles', ['allarticles' => $searcharticles])->render();
return response()->json($scontent);
}
}
}
示例11: Article
function article_unique_title($str)
{
$this->form_validation->set_message('article_unique_title', 'Es existier bereits ein Artikel mit diesem Titel.');
$article = new Article();
$article->where('title', $str)->get();
if ($article->exists()) {
return FALSE;
}
return TRUE;
}
示例12: index
function index($category_id = FALSE)
{
$articles = new Article();
if ($category_id) {
$category = new Category($category_id);
$articles->where("category_id in (select id from categories where lft >= " . $category->lft . " and rgt <= " . $category->rgt . " and module = '" . $category->module . "')");
}
$data['articles'] = $articles->order_by('id', 'desc')->get_page(limit());
$this->template->append_metadata(js_lightbox());
$this->template->build('admin/article_index', $data);
}
示例13: getIndex
public function getIndex()
{
$boards = \Board::where('status', '=', '1')->orderBy('created_at', 'desc')->skip(0)->take(10)->get(array('id', 'name', 'topic', 'count_num', \DB::raw("date_format(created_at,'%Y-%m-%d') as d")));
if ($boards === null) {
$boards = array();
}
$newses = \Article::where('status', '=', '1')->where('category', '=', '3')->where('open_at', '<=', date('Y-m-d'))->orderBy('sort', 'desc')->orderBy('open_at', 'desc')->orderBy('created_at', 'desc')->skip(0)->take(10)->get(array('id', 'title', 'open_at'));
if ($newses === null) {
$newses = array();
}
return \View::make('aesthetics.index.index', array('boards' => &$boards, 'newses' => &$newses));
}
示例14: post_view
public function post_view()
{
$deletedIds = Input::get('delete');
$search = Input::get('search');
$i = 0;
if (isset($deletedIds)) {
foreach ($deletedIds as $delete) {
Article::where('id', '=', $delete)->first()->delete() && ++$i;
}
return Redirect::to('/admin/articles/view')->with('message', $i . " article(s) deleted");
}
if (strlen($search) > 1) {
return Redirect::to('/admin/articles/view?filterby=search&value=' . $search);
}
Input::flush();
return Redirect::to('/admin/articles/view')->with('message', ' [no action performed]');
}
示例15: buildRssData
/**
* Return a string with the feed data
*
* @return string
*/
protected function buildRssData()
{
$now = Carbon::now();
$feed = new Feed();
$channel = new Channel();
$channel->title(config('blog.title'))->description(config('blog.description'))->url(url())->language('en')->copyright('Copyright (c) ' . config('blog.author'))->lastBuildDate($now->timestamp)->appendTo($feed);
$articles = Article::where('published_date', '<=', $now)->orderBy('published_date', 'desc')->take(config('blog.rss_size'))->get();
foreach ($articles as $article) {
$item = new Item();
$item->title($article->title)->tumnail_url($article->thumnail_url)->url($article->url())->pubDate($article->published_date->timestamp)->guid($article->url(), true)->appendTo($channel);
}
$feed = (string) $feed;
// Replace a couple items to make the feed more compliant
$feed = str_replace('<rss version="2.0">', '<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom">', $feed);
$feed = str_replace('<channel>', '<channel>' . "\n" . ' <atom:link href="' . url('/rss') . '" rel="self" type="application/rss+xml" />', $feed);
return $feed;
}