小说站一个书名表,多个章节表,以下是我的查询语法和表,请高手指教,如何优化速度会更好
小说表字段:bid,title,content等
章节表:
CREATE TABLE IF NOT EXISTS `book_capital_1` (
`cid` int(8) unsigned NOT NULL AUTO_INCREMENT,
`bid` int(8) NOT NULL,
`listorder` smallint(5) unsigned NOT NULL DEFAULT '0',
`title` varchar(200) NOT NULL,
`content` text NOT NULL,
`updatetime` int(11) NOT NULL,
`url` varchar(200) NOT NULL,
`juanid` smallint(3) DEFAULT NULL,
`groupid` varchar(10) DEFAULT NULL,
PRIMARY KEY (`cid`),
UNIQUE KEY `cid` (`cid`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8 AUTO_INCREMENT=1;
在页面中好多地方要小说和章节,所以我先调用出小说表中小说信息:
select catid,bid,title,content,updatetime,url,status from book where catid=2
章节我是单独写了个函数调用:
调用:<p>{get_capital($r[bid],28,'','',$r[tableid])}</p>
函数:
function get_capital($bid,$strlength='100',$class='',$order='cid desc',$tableid){
if ($bid=='' or $tableid=='') return false;
$db = pc_base::load_model('book_capital_model');
$db->table_name='book_capital_'.$tableid;
$c_result = $db->get_one(array('bid'=>$bid),'bid,cid,title,url',$order);
$result=str_cut($c_result['title'],$strlength);
if($class=='new_capital' or $class=='reading'){$result='';}
return '<a href="'.$c_result['url'].'" target="_blank" title="'.$c_result['title'].'" class="'.$class.'">'.$result.'</a>';
}
我感觉调用章节这里问题比较多,所以请高手看看。