gpt4 book ai didi

php - 古怪的社交网络墙代码逻辑

转载 作者:行者123 更新时间:2023-11-29 00:48:40 26 4
gpt4 key购买 nike

目标:

从成员(member)墙上拉 - 如果两个 friend 共享相同的 churchMember 关系,则显示流

拉下表:

  • friend
  • 墙贴
  • 用户
  • 教会成员

表结构:

friend 表:

- id, node1id, node2id

墙贴:

- entryData
- postingUserId

用户:

- userpid
- username
- firstname
- lastname

教会成员:

- churchid
- userid

如何将上述要求写入代码?

更新:

选择所有与用户登录时具有相同 churchId 的行与 $churchId = '1';

SELECT * FROM churchMembers WHERE  cMchurchId = $churchId
if $row-cMchurchId == $churchId
SELECT * FROM churchMembers, users WHERE churchMembers.cMuserId = users.userid

最佳答案

这应该让你开始:

$friendId = 5;

$sql = "select w.entryData from wallposts w
inner join church_members cm
on cm.userid = w.postingUserId
where cm.churchid =
(SELECT churchid from church_members where userId='" + $friendId + "'");

好的,如果那些是 friend 表中的userid,你可以这样做:

select w.entryData from friends f
inner join church_members cm on f.node2id = cm.userid //<--friends church
inner join church_members cm2 on f.node1id = cm2.userid //<-- my church
inner join wallposts w on w.postingUserId = f.node2Id //<-- grab the friends wallposts
inner join users u on f.node2id = u.userpid //<-- grab the user data
where cm2.church_id = cm.church_id //<-- they got's to be the same :)

关于php - 古怪的社交网络墙代码逻辑,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9446179/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com