Heim >Backend-Entwicklung >PHP-Tutorial >discuz中这样的sql如何写
条件是: 某版块的某分类信息的数据
某个板块下的可以显示的分类信息(可用)
function get_threadclass($fid){ $threadtypes = C::t('forum_forumfield')->fetch($fid); $threadtypes = dunserialize($threadtypes['threadtypes']); foreach(C::t('forum_threadclass')->fetch_all_by_fid($fid) as $type) { if(isset($threadtypes['types'][$type['typeid']])) { $return[]=$type; } } return $return; }
某个板块下的可以显示的分类信息(可用)
function get_threadclass($fid){ $threadtypes = C::t('forum_forumfield')->fetch($fid); $threadtypes = dunserialize($threadtypes['threadtypes']); foreach(C::t('forum_threadclass')->fetch_all_by_fid($fid) as $type) { if(isset($threadtypes['types'][$type['typeid']])) { $return[]=$type; } } return $return; }
discuz中的表有一点很让人闹心,那就是很多表中的字段没有关联性,都是独立的,所以无法做出关系条件来
某个板块下的可以显示的分类信息(可用)
function get_threadclass($fid){ $threadtypes = C::t('forum_forumfield')->fetch($fid); $threadtypes = dunserialize($threadtypes['threadtypes']); foreach(C::t('forum_threadclass')->fetch_all_by_fid($fid) as $type) { if(isset($threadtypes['types'][$type['typeid']])) { $return[]=$type; } } return $return; }
pre_forum_thread里的字段typeid就是分类信息的id