为什么WP_TERM_TASTIONY表中没有为Term_id编制索引?

时间:2018-01-18 作者:Siddharth Tikekar

每一个categorytag (即电子设备)作为术语存储在wp_terms 索引为的表nameslug, 它与分类学的关系存储在wp_term_taxonomy 索引为的表taxonomyterm_taxonomy_id.

我可以找到term_id 从…起wp_terms 表格使用name 因为它的索引name, 但我必须使用term_id 进一步查找term_taxonomy_id 从…起wp_term_taxonomy 表,但其索引为taxonomy 但不是term_id, 然后我会使用term_taxonomy_id 要查找object_id (posts) 从…起wp_term_relationship 桌子

Question is, why wp_term_taxonomy table is not indexed with term_id which is important in operations like finding posts related to a particular category or tag or anything else?

1 个回复
SO网友:janh

理论上,一个术语可以出现在多个分类中(并且每个分类中有不同的描述)。这就是term\\u taxonomy\\u id发挥作用的地方,它引用单个分类中的单个术语。

实际上,WP试图避免这种情况,并将创建一个具有相同名称和-2 (iirc)如果在不同的分类法中已经存在具有相同slug的术语,则slug上的后缀。

结束

相关推荐

Database Name Change

我读到,使用wp\\uu之外的其他东西作为数据库前缀更安全,所以我下载了我的数据库前缀wp\\uuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuu