PHP头条
热点:

自个儿动手写PHPacts_as_taggable_on实现


自己动手写 PHP acts_as_taggable_on 实现
写道 这个功能不怎么好总结,看了很多PHP相关的资料 感觉都木有讲清楚,ZF和orm的实现又过于臃肿....

只好 参阅rails的acts_as_taggable_on 说白了 核心就一个sql

select post.*,count(tag.id) as count

from post,tag,taging

where post.id!={当前post.id} #排除自身
and post.id=taging.post_id #限定标签的范围为当前post所拥有的标签集合
and taging.tag_type=post.base_class #限定标签类型为当前post的基本类型
and taging.tag_id=tag.id #限定必须是有效的标签
and tag.name in ({当前post拥有的标签})

group by post.id
order by count desc

鄙视 某些人 教程说完一半后面就没了...

简单的东西都复杂话了 ?

www.phpzy.comtrue/phprm/34592.htmlTechArticle自个儿动手写PHPacts_as_taggable_on实现 自己动手写 PHP acts_as_taggable_on 实现 写道这个功能不怎么好总结,看了很多PHP相关的资料 感觉都木有讲清楚,ZF和orm的实现又过于臃肿.... 只好 参阅rai...

相关文章

PHP之友评论

今天推荐