WordPressMU - 获取博客列表,按博客名称字母顺序排序
在 WordPress MU 中,我尝试为此编写自己的查询,但似乎无法获得我真正需要的所有联接。我正在寻找的结果集类似于:
blog_id
blog name
blog path
owner first name
owner last name
并按博客名称的字母顺序返回全部内容。我遇到的问题是博客所有者的名字和姓氏在 wp_usermeta 中,博客 ID 和路径在 wp_blogs 中,博客名称在 wp_[这里是博客 id]_options 中,wp_usermeta 需要用户 ID来自 wp_users。
是否可以在一个查询中加入所有这些内容?
In WordPress MU, I've tried writing my own query for this but can't seem to get all of the joins I really need. The result set I'm looking for would be something like:
blog_id
blog name
blog path
owner first name
owner last name
and return it all alphabetically, by blog name. The trouble I'm having is that the first and last name of the blog owner are in wp_usermeta, the blog id and path are in wp_blogs, and the blog name is in wp_[blog id here]_options, with wp_usermeta requiring the user ID from wp_users.
Is it possible to join all of this in one query?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
由于 WPMU 处理数据库表名称的方式,无法将所有信息组合到一个结果集中。
我提出的最佳解决方案是一些 PHP 逻辑,它从 wp_blogs 表中获取博客,使用其中的 ID 从 wp_X_options 表中收集信息,然后构建我需要的信息。出于同样的原因,没有好的方法可以仅通过查询来获取所有博客中的所有帖子的列表。您需要后端逻辑来基于 wp_blogs 中的博客构建查询。
There is not a way to combine all of the information into one result set because of the way WPMU handles the database table names.
The best solution I have come up with is some PHP logic that gets the blogs from the wp_blogs table, uses the IDs there to gather information from the wp_X_options tables, and then builds up the information I need. It's the same reason there is no good way to get a list of all the posts across all of the blogs with just a query. You need backend logic to build the query based on the blogs in wp_blogs.