discuz代码分析之左连接 t1 left join t2 on t1.id=t2.uid where...
来源:互联网 发布:c#9语言高级编程 pdf 编辑:程序博客网 时间:2024/05/17 23:52
<?php//本地头条$page = isset($_GET['page']) ? (int)$_GET['page'] : 1;if($page < 1) { $page = 1;}$limit = 20; // 每页显示条数$offset = ($page - 1) * $limit;//$total = DB::result_first('SELECT COUNT(*) FROM '.DB::table('common_block_item')." WHERE bid = ".ODZ_NEWS_BLOCK_ID);$total = DB::result_first('SELECT count(*) FROM '.DB::table('common_block_item')." WHERE bid = ".ODZ_NEWS_BLOCK_ID);$sql = 'SELECT c.id, c.title, c.pic, c.picflag, c.makethumb, c.thumbpath, c.summary, c.fields,f.views FROM '.DB::table('common_block_item')." as c left join ".DB::table('forum_thread')." as f on c.id = f.tid WHERE c.bid = ".ODZ_NEWS_BLOCK_ID." AND f.displayorder IN(0,1,2,3) ORDER BY c.displayorder ASC LIMIT $offset, $limit";if(strpos($_G['setting']['attachurl'],'http') !== false){ $img_url = $_G['setting']['attachurl'];}else{ $img_url = $_G['baseurl'].$_G['setting']['attachurl'];}$query = DB::query($sql);$list = array();while ($row = DB::fetch($query)) { $row['fields'] = unserialize($row['fields']); if(!$row['fields']['dateline']) { continue; } $arr = array( 'id' => (string)$row['id'], 'title' => (string)odz_format_subject($row['title']), 'replies' => (string)$row['fields']['replies'], 'dateline' => my_date_format($row['fields']['dateline'],'m-d'), 'views'=>(string)$row['views'], ); // 强制要求生成缩略图 if($row['makethumb']) { $imgpath = $row['thumbpath']; } else { $imgpath = $row['pic']; } $arr['thumb'] = $thumburl; // 截取简介 $arr['summary'] = str_replace(array("\r\n", "\r", "\n"), '', $row['summary']);// $arr['summary'] = str_replace(" ", '', $arr['summary']); $arr['summary'] = cutstr($arr['summary'], (count($thumburl) ? 45 : 75));//根据picflag 确认图片url if($row['picflag'] == 0){ if(strpos($_G['setting']['attachurl'],'http') !== false){ $img_url = $_G['setting']['attachurl']; }else{ $img_url = $_G['baseurl'].$_G['setting']['attachurl']; } $arr['thumb'] = array($img_url.$imgpath); }elseif($row['picflag'] == 2){ $arr['thumb'] = array($_G['setting']['ftp']['attachurl'].$imgpath); }else{ $arr['thumb'] = array($img_url.$imgpath); } if(strpos($arr['thumb'][0],'nophoto.gif') !== false ){ $arr['thumb'] = array(); } $list[] = $arr;}$result = array( 'total' => $total['count(*)']?ceil(($total)/20):'0', // 'perpage' => $limit, // 'page' => $page, 'list' => $list);?>
0 0
- discuz代码分析之左连接 t1 left join t2 on t1.id=t2.uid where...
- srm 526 T1 && T2
- srm527 T1 && T2
- sm 528 T1 && T2
- SRM 608 T1 && T2
- BeanUtils<T1, T2> beanToBean
- 【队内胡策 11.1】 T1 T2
- 【队内胡策 11.3】 T1 T2
- SRM 605 T1 T2 T3
- 左连接 A left join B on A.a = B.a and/where的区别
- 磁共振中的T1, T2 和 T2*的原理和区别
- Func<T1, T2, TResult> 泛型委托
- 磁共振T1 T2 T1WI T2WI含义
- Dictionary<T1,T2>和Hashtable的异同
- 【JLOI2013】T1、T2、T3 Bzoj3190~3192
- SIP协议中的T1和T2
- NOIP 2013 day 2 t1 t2
- 51nod 1097 拼成最小的数 思维题 t1+t2<t2+t1
- 利用原生js提升jquery选择器的性能
- V-Play 文档翻译 Page
- HDU 2553 N皇后问题
- Git使用流程
- Yii2 where
- discuz代码分析之左连接 t1 left join t2 on t1.id=t2.uid where...
- 206. Reverse Linked List
- 【ibatis】ssi 框架 ibatis 分页实现
- Android Studio如何删除module
- DEDECMS发布时间为1970年1月1日的解决方法
- 系统默认alert弹出框域名title问题
- WebService的两种方式SOAP和REST比较
- 类与对象
- iOS 播放音效