一区二区三区在线-一区二区三区亚洲视频-一区二区三区亚洲-一区二区三区午夜-一区二区三区四区在线视频-一区二区三区四区在线免费观看

服務(wù)器之家:專注于服務(wù)器技術(shù)及軟件下載分享
分類導(dǎo)航

PHP教程|ASP.NET教程|Java教程|ASP教程|編程技術(shù)|正則表達(dá)式|C/C++|IOS|C#|Swift|Android|VB|R語言|JavaScript|易語言|vb.net|

服務(wù)器之家 - 編程語言 - PHP教程 - php 文章調(diào)用類代碼

php 文章調(diào)用類代碼

2019-12-10 13:32PHP代碼網(wǎng) PHP教程

自己寫的MonolithCMS上面用到的文章類,可能不是很通用, 但是勝在我有全部的注釋

調(diào)用方法如下: 

復(fù)制代碼代碼如下:


$Template= '<li class="xxx">[<a href="{catedir}">{catetitle}</a>]<a href="{html}" /> 類代碼如下: 

復(fù)制代碼代碼如下:


<?php 
/** 
* 文章類,方便文章列表、內(nèi)容的調(diào)用 
* 僅支持PHP5 

* 類函數(shù)列表: 
* getArticleListByCateId(); 

* @author Zerolone 
* @version 2011-3-14 9:53:42 

* 2011-1-31 10:11:07 增加靜態(tài)方法 getCatePreviewUrl getPreviewUrl 
*/ 
class Article { 
public $CateId = 0; //欄目編號 0,可以為一個欄目編號, 或者多個欄目。例如:12, 或者12,13 
public $Count = 10; //記錄數(shù) 10 
public $TitleCount = 20; //文字顯示數(shù) 20 
public $BeginCount = 0; //起始記錄數(shù) 0 
public $OrderBy = 'id'; //排序字段 默認(rèn)以id字段排序 
public $OrderSort = 'DESC'; //排序順序 默認(rèn)DESC,倒序 
public $OrderBy2 = ''; //排序字段2 
public $OrderSort2 = ''; //排序順序2 
public $Area = 0; //顯示區(qū)域 0,全部顯示 
public $Flag = ISSUEFLAG; //顯示文章狀態(tài) 2,2為 已保存 已發(fā)布 
public $Pic = 0; //僅調(diào)用有圖片的 0,1為僅調(diào)用有圖的 
public $Video = 0; //僅調(diào)用有視頻的 0,1為僅調(diào)用視頻的 
public $notshowlist= 0; //不顯示不在列表中的 0,不顯示, 1 顯示 
public $AndWhere = ''; //額外加入的查詢 
public $Loop = 0; //循環(huán)列表 0, 
public $Template = ''; //模板 
public $IdList = ''; //Id列表,用于外部調(diào)用 
//內(nèi)部使用的變量 
protected $SqlCateId = ''; //欄目Sql語句 
protected $SqlCateTitleId = ''; //欄目Sql語句 
protected $SqlArea = ''; //顯示區(qū)域Sql語句 
protected $SqlFlag = ''; //狀態(tài) 
protected $SqlNotShow = ''; //不顯示列表中 
protected $SqlPic = ''; //是否僅調(diào)用圖片 
protected $SqlVideo = ''; //是否僅調(diào)用視頻 
protected $SqlOrder = ''; //排序 
protected $SqlLimit = ''; //顯示個數(shù) 
protected $SqlWhere = ''; //加入查詢 
public $SqlStr = ''; //調(diào)試用 
/** 
* 初始化Sql語句 

*/ 
function InitSql(){ 
//欄目編號 
$CateId=$this->CateId; 
if (strpos($CateId, ',')) { 
$this->SqlCateId=' AND `cateid` in ('.$CateId.')'; 
} elseif ($CateId>0) { 
$this->SqlCateId=' AND `cateid` ='.$CateId; 

if ($CateId==0) $this->SqlCateId=''; 
/* 
$CateId=$this->CateId; 
$this->SqlCateTitleId=' AND `id` ='.$CateId; 
*/ 
//顯示區(qū)域 
$Area=$this->Area; 
if ($Area>0) { 
$Area+=0; 
$this->SqlArea= ' AND `area'.$Area.'` =1'; 

//狀態(tài) 
$this->SqlFlag= ' AND `flag` = '. $this->Flag; 
//列表中不顯示 
$this->SqlNotShow= ' AND `notshowlist` = '. $this->notshowlist; 
//圖片 
$Pic = $this->Pic; 
if ($Pic==1){ 
$this->SqlPic= ' AND (`pic1` <>"" or `pic2`<>"") '; 
}else { 
$this->SqlPic= ''; 

//視頻 
$Video = $this->Video; 
if ($Video==1){ 
$this->SqlVideo= ' AND `isvideo`=1 '; 
}else { 
$this->SqlVideo= ''; 

//額外加入的查詢 
$AndWhere = $this->AndWhere; 
if ($AndWhere<>''){ 
$this->SqlWhere = ' And ' . $AndWhere; 

//排序 
$this->SqlOrder= ' ORDER BY `'.$this->OrderBy.'` '.$this->OrderSort; 
if ($this->OrderBy2!='') $this->SqlOrder.= ' ,`'.$this->OrderBy2.'` '.$this->OrderSort2; 
//顯示個數(shù) 
$this->SqlLimit= ' LIMIT '.$this->BeginCount.', '.$this->Count.';'; 

/** 
* 清除,置為默認(rèn) 
*/ 
function Clear(){ 
$this->CateId = 0; //欄目編號 0,可以為一個欄目編號, 或者多個欄目。例如:12, 或者12,13 
$this->Count = 10; //記錄數(shù) 10 
$this->TitleCount = 20; //文字顯示數(shù) 20 
$this->BeginCount = 0; //起始記錄數(shù) 0 
$this->OrderBy = 'id'; //排序字段 默認(rèn)以id字段排序 
$this->OrderSort = 'DESC'; //排序順序 默認(rèn)DESC,倒序 
$this->Area = 0; //顯示區(qū)域 0,全部顯示 
$this->Flag = ISSUEFLAG; //顯示文章狀態(tài) 2,2為 已保存 已發(fā)布 
$this->Pic = 0; //僅調(diào)用有圖片的 0,1為僅調(diào)用有圖的 
$this->Video = 0; //僅調(diào)用有視頻的 0,1為僅調(diào)用視頻的 
$this->notshowlist = 0; //不顯示不在列表中的 0,不顯示, 1 顯示 
$this->AndWhere = ''; //額外加入的查詢 
$this->Loop = 0; //循環(huán)列表 0, 
$this->Template = ''; //模板 

/** 
* 返回文章內(nèi)容字符串 

* {<li class="xxx"><a href="{html}" /> 數(shù)據(jù)庫 

復(fù)制代碼代碼如下:


-- 
-- 表的結(jié)構(gòu) `mc_article` 
-- 
CREATE TABLE IF NOT EXISTS `mc_article` ( 
`id` int(10) unsigned NOT NULL auto_increment COMMENT '編號', 
`comment` tinyint(3) unsigned NOT NULL COMMENT '是否留言', 
`comments` tinyint(3) unsigned NOT NULL COMMENT '留言條數(shù)', 
`commentcheck` tinyint(3) unsigned NOT NULL COMMENT '回復(fù)審核', 
`posttime` int(10) unsigned NOT NULL COMMENT '提交時間', 
`title` varchar(255) NOT NULL COMMENT 'Title', 
`title2` varchar(255) default NULL COMMENT 'Title2', 
`content` text COMMENT 'Content', 
`flag` tinyint(1) NOT NULL default '0' COMMENT '標(biāo)志', 
`cateid` int(10) unsigned NOT NULL default '0' COMMENT '欄目編號', 
`sourceid` mediumint(8) unsigned NOT NULL default '0', 
`reurl` varchar(255) default NULL COMMENT '跳轉(zhuǎn)地址', 
`hits` mediumint(8) unsigned NOT NULL default '0' COMMENT '點擊數(shù)', 
`author` varchar(255) default NULL COMMENT '作者', 
`from` varchar(255) default NULL COMMENT '來源', 
`keyword` varchar(255) default NULL COMMENT '關(guān)鍵字', 
`order` tinyint(4) unsigned NOT NULL default '99' COMMENT '順序', 
`memo` text COMMENT '簡介', 
`pic1` varchar(255) default NULL COMMENT '圖片一', 
`pic2` varchar(255) default NULL COMMENT '圖片二', 
`userid` int(10) unsigned NOT NULL default '0' COMMENT '用戶編號', 
`html` varchar(255) default NULL COMMENT '地址', 
`ishtml` tinyint(3) unsigned NOT NULL default '0' COMMENT '是否生成', 
`area` int(10) unsigned NOT NULL default '0' COMMENT '顯示區(qū)域', 
`custom1` varchar(255) default NULL COMMENT '自定義1', 
`custom2` varchar(255) default NULL COMMENT '自定義2', 
`custom3` varchar(255) default NULL COMMENT '自定義3', 
`custom4` varchar(255) default NULL COMMENT '自定義4', 
`custom5` varchar(255) default NULL COMMENT '自定義5', 
`res_id` int(10) unsigned NOT NULL default '0', 
`special` varchar(255) default NULL, 
`area1` tinyint(1) unsigned NOT NULL default '0', 
`area2` tinyint(1) unsigned NOT NULL default '0', 
`area3` tinyint(1) unsigned NOT NULL default '0', 
`area4` tinyint(1) unsigned NOT NULL default '0', 
`area5` tinyint(1) unsigned NOT NULL default '0', 
`isvideo` tinyint(1) unsigned NOT NULL default '0' COMMENT '是否視頻節(jié)目', 
`notshowlist` tinyint(4) NOT NULL default '0' COMMENT '不顯示在列表', 
`titlecolor` varchar(7) default NULL COMMENT '標(biāo)題顏色', 
`url` varchar(255) default NULL, 
PRIMARY KEY (`id`) 
) ENGINE=MyISAM DEFAULT CHARSET=utf8 COMMENT='Article' AUTO_INCREMENT=87 ; 
-- 
-- 轉(zhuǎn)存表中的數(shù)據(jù) `mc_article` 
-- 
INSERT INTO `mc_article` (`id`, `comment`, `comments`, `commentcheck`, `posttime`, `title`, `title2`, `content`, `flag`, `cateid`, `sourceid`, `reurl`, `hits`, `author`, `from`, `keyword`, `order`, `memo`, `pic1`, `pic2`, `userid`, `html`, `ishtml`, `area`, `custom1`, `custom2`, `custom3`, `custom4`, `custom5`, `res_id`, `special`, `area1`, `area2`, `area3`, `area4`, `area5`, `isvideo`, `notshowlist`, `titlecolor`, `url`) VALUES 
(1, 0, 0, 0, 0, '學(xué)堂介紹', '', '<DL>\r\n<DD> </DD>\r\n<DT><FONT style="BACKGROUND-COLOR: #0000ff" color=#800000>【測試修改】</FONT>重慶漫想族文化<FONT color=#ff0000>傳播有限公司是一家集合原創(chuàng)</FONT>動畫、娛樂產(chǎn)品開發(fā),提供多媒體制作并以電視、網(wǎng)絡(luò)傳播為平臺的現(xiàn)代化動漫文化開發(fā)推廣策劃制作公司。于2008年4月入駐重慶高新開發(fā)區(qū)北部新區(qū)重慶動漫基地。<BR>漫想族公司通過自己多<STRONG>年的管理運作,建立了西南地區(qū)最</STRONG>大的無紙動畫生產(chǎn)基地,集合了業(yè)界內(nèi)最優(yōu)秀的精英的團隊。并與國內(nèi)多家影視機構(gòu)、出版社、數(shù)字藝術(shù)廠商、多媒體平臺建立了良好的合作關(guān)系,實現(xiàn)優(yōu)勢互補、資源共享,在業(yè)界和市場上都形成了廣泛和深遠(yuǎn)的影響力。<BR>目前公司主要從事原創(chuàng)電視動畫、原創(chuàng)電影動畫等品牌產(chǎn)品的開發(fā),同時還涉及光盤出版、圖書制作發(fā)行、廣告制作、游戲開發(fā)以及文化產(chǎn)品授權(quán)等業(yè)務(wù)領(lǐng)域。漫想族公司一直堅定信奉精品至上路線,努力為社會奉獻(xiàn)精品,努力開拓中國動漫市場。漫想族公司一直堅定信奉精品至上路線,努力為社會奉獻(xiàn)精品,努力開拓中國動漫市場。漫想族公司一直堅定信奉精品至上路線,努力為社會奉獻(xiàn)精品,努力開拓中國動漫市場。</DT>\r\n<P class=clrB></P></DL>', 0, 28, 0, '', 2, '', '', '', 255, '', '', '', 1, NULL, 0, 0, NULL, NULL, NULL, NULL, NULL, 0, NULL, 0, 0, 0, 0, 0, 0, 0, '', NULL), 
(2, 0, 0, 0, 0, '公司簡介', '', '公司簡介公司簡介公司簡介公司簡介公司簡介公司簡介公司簡介公司簡介公司簡介公司簡介', 1, 28, 0, '', 0, '', '', '', 255, '', '', '', 1, NULL, 0, 0, NULL, NULL, NULL, NULL, NULL, 0, NULL, 0, 0, 0, 0, 0, 0, 0, '', NULL), 
(3, 0, 0, 0, 0, '最新動態(tài)', '', '<P><IMG /> 分類結(jié)構(gòu) 

復(fù)制代碼代碼如下:


-- -------------------------------------------------------- 
-- 
-- 表的結(jié)構(gòu) `mc_article_cate` 
-- 
CREATE TABLE IF NOT EXISTS `mc_article_cate` ( 
`id` int(10) unsigned NOT NULL auto_increment, 
`parentid` int(10) default NULL, 
`level` char(50) default NULL, 
`title` char(100) default NULL, 
`templateid` int(10) default NULL, 
`forumid` int(10) default NULL, 
`catetemplateid` int(10) default NULL, 
`dir` char(100) default NULL, 
`kind` tinyint(4) default '0' COMMENT '顯示方式', 
`pagesize` tinyint(4) default '0' COMMENT '顯示條數(shù)', 
`specialid` int(10) default '0' COMMENT '對應(yīng)專題編號', 
`url` varchar(255) NOT NULL, 
PRIMARY KEY (`id`) 
) ENGINE=MyISAM DEFAULT CHARSET=utf8 COMMENT='cate' AUTO_INCREMENT=40 ; 
-- 
-- 轉(zhuǎn)存表中的數(shù)據(jù) `mc_article_cate` 
-- 
INSERT INTO `mc_article_cate` (`id`, `parentid`, `level`, `title`, `templateid`, `forumid`, `catetemplateid`, `dir`, `kind`, `pagesize`, `specialid`, `url`) VALUES 
(1, 0, '01', '測試大類', 9, NULL, 9, '/test/', 0, 0, 0, ''), 
(3, 0, '03', '樓盤調(diào)用', NULL, NULL, NULL, 'getbuild', 0, 0, 0, ''), 
(4, 0, '04', '學(xué)習(xí)環(huán)境', NULL, NULL, NULL, '/asdf/', 0, 0, 0, ''), 
(5, 0, '05', '報名方式', NULL, NULL, NULL, NULL, 0, 0, 0, ''), 
(6, 0, '06', '學(xué)員作品', NULL, NULL, NULL, NULL, 0, 0, 0, ''), 
(7, 0, '07', '校院合作', NULL, NULL, NULL, NULL, 0, 0, 0, ''), 
(38, 0, '17', '購房寶典', 2, NULL, 2, 'baodian', 0, 0, 0, ''), 
(25, 6, '0601', '插畫學(xué)員作品', NULL, NULL, NULL, NULL, 0, 0, 0, 'works.php'), 
(26, 6, '0602', '動畫學(xué)員作品', NULL, NULL, NULL, NULL, 0, 0, 0, 'works.php'), 
(28, 0, '08', '調(diào)用文章', NULL, NULL, NULL, NULL, 0, 0, 0, ''), 
(29, 3, '0301', '新上市', NULL, NULL, NULL, 'getbuild/new', 0, 0, 0, ''), 
(30, 3, '0302', '本月開盤', NULL, NULL, NULL, 'getbuild/this', 0, 0, 0, ''), 
(31, 3, '0303', '下月開盤', NULL, NULL, NULL, 'getbuild/next', 0, 0, 0, ''), 
(32, 25, '060101', '第一期', NULL, NULL, NULL, NULL, 0, 0, 0, ''), 
(33, 25, '060102', '第二期', NULL, NULL, NULL, NULL, 0, 0, 0, ''), 
(34, 25, '060103', '第三期', NULL, NULL, NULL, NULL, 0, 0, 0, ''), 
(35, 25, '060104', '第四期', NULL, NULL, NULL, NULL, 0, 0, 0, ''), 
(36, 26, '060201', '第一期', NULL, NULL, NULL, NULL, 0, 0, 0, ''), 
(39, 1, '0101', 'sf', 9, NULL, 2, '/test/sub/', 0, 0, 0, ''); 


視圖代碼: 

復(fù)制代碼代碼如下:


-- 視圖結(jié)構(gòu) `mc_view_article` 
CREATE VIEW `mc_view_article` AS select `mc_article`.`id` AS `id`,`mc_article`.`comment` AS `comment`,`mc_article`.`comments` AS `comments`,`mc_article`.`commentcheck` AS `commentcheck`,`mc_article`.`posttime` AS `posttime`,`mc_article`.`title` AS `title`,`mc_article`.`title2` AS `title2`,`mc_article`.`content` AS `content`,`mc_article`.`flag` AS `flag`,`mc_article`.`cateid` AS `cateid`,`mc_article`.`sourceid` AS `sourceid`,`mc_article`.`reurl` AS `reurl`,`mc_article`.`hits` AS `hits`,`mc_article`.`author` AS `author`,`mc_article`.`from` AS `from`,`mc_article`.`keyword` AS `keyword`,`mc_article`.`order` AS `order`,`mc_article`.`memo` AS `memo`,`mc_article`.`pic1` AS `pic1`,`mc_article`.`pic2` AS `pic2`,`mc_article`.`userid` AS `userid`,`mc_article`.`html` AS `html`,`mc_article`.`ishtml` AS `ishtml`,`mc_article`.`area` AS `area`,`mc_article`.`custom1` AS `custom1`,`mc_article`.`custom2` AS `custom2`,`mc_article`.`custom3` AS `custom3`,`mc_article`.`custom4` AS `custom4`,`mc_article`.`custom5` AS `custom5`,`mc_article`.`res_id` AS `res_id`,`mc_article`.`special` AS `special`,`mc_article`.`area1` AS `area1`,`mc_article`.`area2` AS `area2`,`mc_article`.`area3` AS `area3`,`mc_article`.`area4` AS `area4`,`mc_article`.`area5` AS `area5`,`mc_article`.`isvideo` AS `isvideo`,`mc_article`.`titlecolor` AS `titlecolor`,`mc_article`.`url` AS `url`,`mc_article`.`notshowlist` AS `notshowlist`,`mc_article_cate`.`parentid` AS `parentid`,`mc_article_cate`.`level` AS `level`,`mc_article_cate`.`title` AS `ctitle`,`mc_article_cate`.`templateid` AS `templateid`,`mc_article_cate`.`forumid` AS `forumid`,`mc_article_cate`.`catetemplateid` AS `catetemplateid`,`mc_article_cate`.`dir` AS `dir`,`mc_article_cate`.`kind` AS `kind`,`mc_article_cate`.`pagesize` AS `pagesize`,`mc_article_cate`.`specialid` AS `specialid`,`mc_article_cate`.`url` AS `curl` from (`mc_article` join `mc_article_cate` on((`mc_article`.`cateid` = `mc_article_cate`.`id`))); 

延伸 · 閱讀

精彩推薦
主站蜘蛛池模板: 久久精品国产免费 | 婚前试爱全集免费观看 | 久久视频在线视频观看天天看视频 | 亚洲a视频在线观看 | 精品免费视在线视频观看 | 69午夜影院 | 欧美洲大黑香蕉在线视频 | 亚洲国产综合网 | 成人福利在线观看 | 超91精品手机国产在线 | 欧美整片在线 | 国产成年人视频 | 精品在线观看一区 | 日本一区三区 | 91制片厂(果冻传媒)原档破解 | 亚洲人成影院午夜网站 | 亚洲六月丁香六月婷婷蜜芽 | 欧美日韩视频在线第一区二区三区 | 国语自产拍在线观看7m | 红色毛片| 女教师系列三上悠亚在线观看 | 91青青国产在线观看免费 | 成人午夜影院在线观看 | 成年人视频免费在线播放 | 色欲麻豆国产福利精品 | 羞羞视频免费观 | 男人j放进女人的p视频免费 | 日韩综合久久 | 毛片大全高清免费 | 91麻豆精品国产自产在线观看 | 4455永久在线视频观看 | www毛片| 91精品综合久久久久久五月天 | 国产精品国产三级国产专区不 | 日韩 视频在线播放 | 国产成人精品午夜免费 | 免费黄色片网站 | 日本妇人成熟免费观看18 | free哆拍拍免费永久视频 | 我的奶头被客人吸的又肿又红 | 97福利社|