Home > Backend Development > PHP Tutorial > discuz中这样的sql如何写

discuz中这样的sql如何写

WBOY
Release: 2016-06-23 13:48:01
Original
1129 people have browsed it

条件是: 某版块的某分类信息的数据


回复讨论(解决方案)

某个板块下的可以显示的分类信息(可用)

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;	}
Copy after login
Copy after login
Copy after login

某个板块下的可以显示的分类信息(可用)

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;	}
Copy after login
Copy after login
Copy after login




好象我的表述有点问题: 是这样
我主要是想要帖子中的message字段里的信息,条件是 该版块下的 A子版块中的 D主题分类的所有帖子中的 message的内容
我想了一下,好象是要用到 pro_forum_post这个表及主题分类表 pre_forum_threadclass

因为 pro_forum_post里面有message帖子内容信息的字段,而 pre_forum_threadclass里面是主题分类的表,但是这两个表如何关联呢?

我写了一个句子,查不出来,不知哪里错了。
我是这样写的:SELECT sh_forum_post.message, sh_forum_post.fid FROM sh_forum_post, sh_forum_threadclass WHERE sh_forum_post.fid = 128 AND sh_forum_threadclass.`name` = '美丽图片'

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;	}
Copy after login
Copy after login
Copy after login



好象有点门,我是这样想的,论坛里默认的源码中,点那些主题分类就可以出现我要的效果,看来源码中就有这句sql
那,他是怎么写的呢,它的地址是这样,帮我分析一下,谢谢你 jam00,
http://127.0.0.1/forum.php?mod=forumdisplay&fid=129&filter=typeid&typeid=26

pre_forum_thread里的字段typeid就是分类信息的id

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template