本文整理匯總了PHP中Articles::leftJoin方法的典型用法代碼示例。如果您正苦於以下問題:PHP Articles::leftJoin方法的具體用法?PHP Articles::leftJoin怎麽用?PHP Articles::leftJoin使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類Articles
的用法示例。
在下文中一共展示了Articles::leftJoin方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: articlePreview
/**
* 顯示文章頁
*
* @param int $id 文章id
*/
public function articlePreview($id, $result = array())
{
if ($_SERVER["HTTP_HOST"] != "ht.5067.org") {
$article = Articles::find($id);
$customer_info = CustomerInfo::where('cus_id', $this->cus_id)->first();
if ($customer_info->lang == 'en') {
$lang['the_last'] = 'The last one';
$lang['the_first'] = 'The first one';
} else {
$lang['the_last'] = '已經是最後一篇';
$lang['the_first'] = '已經是第一篇';
}
$a_moreimg = Moreimg::where('a_id', $id)->get()->toArray();
array_unshift($a_moreimg, array('title' => $article->title, 'img' => $article->img));
$images = array();
if (count($a_moreimg)) {
$i = 0;
foreach ($a_moreimg as $a_img) {
$images[$i]['title'] = $a_img['title'];
$images[$i]['image'] = $a_img['img'] ? $this->source_dir . 'l/articles/' . $a_img['img'] : '';
$i++;
}
}
$list_id = Articles::where('c_id', $article->c_id)->where($this->type . '_show', '1')->where('use_url', '0')->orderBy('is_top', 'desc')->orderBy('sort', 'asc')->orderBy('created_at', 'desc')->select('id', 'title', 'img', 'introduction', 'created_at')->lists('id');
foreach ((array) $list_id as $key => $val) {
$article_prev = NULL;
$article_next = NULL;
if ($val == $id) {
if ($key != 0) {
$prev_id = $list_id[$key - 1];
$article_prev = Articles::find($prev_id);
}
if ($key < count($list_id) - 1) {
$next_id = $list_id[$key + 1];
$article_next = Articles::find($next_id);
}
break;
}
}
$result = $this->pagePublic($article->c_id);
if (is_array($result['navs']) && !empty($result['navs'])) {
foreach ((array) $result['navs'] as $nav) {
if ($nav['current'] == 1) {
$pagenavs = $nav['childmenu'];
break;
} else {
$pagenavs = array();
}
}
}
if (empty($pagenavs)) {
$pagenavs = array();
}
$result['pagenavs'] = $pagenavs;
$result['posnavs'] = $this->getPosNavs($article->c_id);
$result['title'] = $customer_info->title != "" ? $customer_info->title . '-' . $article->title : $article->title;
$result['keywords'] = $article->keywords != "" ? $article->keywords : $customer_info->keywords;
$result['description'] = $article->introduction != "" ? $article->introduction : $customer_info->description;
$result['article']['title'] = $article->title;
$result['article']['keywords'] = $article->keywords;
$result['article']['description'] = $article->introduction;
$result['article']['viewcount'] = '<em id="article-viewcount">0</em>';
$result['enlarge'] = 0;
$article_type = Articles::leftJoin('classify', 'classify.id', '=', 'article.c_id')->where('article.id', $id)->pluck('article_type');
if ($article_type == 1) {
//新聞內容
$viewname = 'content-news';
} elseif ($article_type == 2) {
//產品內容
$viewname = 'content-product';
$result['enlarge'] = $customer_info->enlarge;
if ($result['enlarge'] && $this->type == 'pc') {
$result['footscript'] .= '<script type="text/javascript" src="http://swap.5067.org/js/img.js"></script>';
}
} else {
//跳轉404
}
//關聯文章查詢
// $pa = new PhpAnalysis();
//
// $pa->SetSource($article->title);
//
// //設置分詞屬性
// $pa->resultType = 2;
// $pa->differMax = true;
// $pa->StartAnalysis();
//
// //獲取你想要的結果
// $keywords = $pa->GetFinallyIndex();
// if (count($keywords)) {
// $relation_where = "";
// foreach ((array) $keywords as $key => $word) {
// $relation_where.="or title like '%$key%' ";
// }
// $relation_where = ltrim($relation_where, 'or');
//.........這裏部分代碼省略.........
示例2: articlePreview
/**
* 顯示文章頁
*
* @param int $id 文章id
*/
public function articlePreview($id)
{
$article = Articles::find($id);
$a_moreimg = Moreimg::where('a_id', $id)->get()->toArray();
array_unshift($a_moreimg, array('title' => $article->title, 'img' => $article->img));
$images = array();
if (count($a_moreimg)) {
$i = 0;
foreach ($a_moreimg as $a_img) {
$images[$i]['title'] = $a_img['title'];
$images[$i]['image'] = $this->source_dir . 'l/articles/' . $a_img['img'];
$i++;
}
}
$list_id = Articles::where('c_id', $article->c_id)->where($this->type . '_show', '1')->orderBy('is_top', 'desc')->orderBy('created_at', 'desc')->select('id', 'title', 'img', 'introduction', 'created_at')->lists('id');
foreach ($list_id as $key => $val) {
$article_prev = NULL;
$article_next = NULL;
if ($val == $id) {
if ($key != 0) {
$prev_id = $list_id[$key - 1];
$article_prev = Articles::find($prev_id);
}
if ($key < count($list_id) - 1) {
$next_id = $list_id[$key + 1];
$article_next = Articles::find($next_id);
}
break;
}
}
$result = $this->pagePublic($article->c_id);
foreach ($result['navs'] as $nav) {
if ($nav['current'] == 1) {
$pagenavs = $nav['childmenu'];
break;
} else {
$pagenavs = [];
}
}
$result['pagenavs'] = $pagenavs;
$result['posnavs'] = $this->getPosNavs($article->c_id);
$result['title'] = $article->title;
$result['keywords'] = $article->keywords;
$result['description'] = $article->introduction;
$result['article']['title'] = $article->title;
$result['article']['keywords'] = $article->keywords;
$result['article']['description'] = $article->introduction;
$result['article']['viewcount'] = '<em id="article-viewcount">0</em>';
$article_type = Articles::leftJoin('classify', 'classify.id', '=', 'article.c_id')->where('article.id', $id)->pluck('article_type');
if ($article_type == 1) {
//新聞內容
$viewname = 'content-news';
} elseif ($article_type == 2) {
//產品內容
$viewname = 'content-product';
} else {
//跳轉404
}
//關聯文章查詢
$pa = new PhpAnalysis();
$pa->SetSource($article->title);
//設置分詞屬性
$pa->resultType = 2;
$pa->differMax = true;
$pa->StartAnalysis();
//獲取你想要的結果
$keywords = $pa->GetFinallyIndex();
if (count($keywords)) {
$relation_where = "";
foreach ($keywords as $key => $word) {
$relation_where .= "or title like '%{$key}%' ";
}
$relation_where = ltrim($relation_where, 'or');
$prefix = Config::get('database.connections.mysql.prefix');
$related_data = DB::select("select id,title,img as image,introduction,created_at,c_id from {$prefix}article where cus_id={$this->cus_id} and ({$relation_where})");
$related = array();
if (count($related_data)) {
foreach ($related_data as $val) {
$temp_arr = [];
$temp_arr['title'] = $val->title;
$temp_arr['description'] = $val->introduction;
$temp_arr['image'] = $this->source_dir . 'l/articles/' . $val->image;
if ($this->showtype == 'preview') {
$temp_arr['link'] = $this->domain . '/detail/' . $val->id;
$temp_arr['category']['link'] = $this->domain . '/category/' . $val->id . '.html';
} else {
$temp_arr['link'] = $this->domain . '/detail/' . $val->id . '.html';
$temp_arr['category']['link'] = $this->domain . '/category/' . $val->id . '.html';
}
$temp_arr['pubdate'] = $val->created_at;
$temp_arr['pubtimestamp'] = strtotime($val->created_at);
$a_c_info = Classify::where('id', $val->c_id)->first();
$temp_arr['category']['name'] = $a_c_info->name;
$temp_arr['category']['en_name'] = $a_c_info->en_name;
$temp_arr['category']['icon'] = '<i class="iconfont">' . $a_c_info->icon . '</i>';
//.........這裏部分代碼省略.........