我正在创建通知页面,其中 显示了4种类型的通知
1) someone liked your post
2) someone shared your post
3) someone added you as a friend
4) someone commented your post
我已经获得了每个语句的sql代码,但我仍然不知道如何在单个while($a=sql_array()){}
循环中混合所有内容,我知道我应该按日期使用UNION和ORDER,但我该怎么做为每种显示的通知发布个性化输出
DESIRED OUTPUT
A liked your page
B comment your post
C liked your page
D comment your post
E added you as a friend
F liked your page
G comment your post
H shared your post
I added you as a friend
J shared your post
K shared your post
L liked your page
M added you as a friend
N shared your post
O added you as a friend
P liked your page
Q comment your post
R added you as a friend
S added you as a friend
T comment your post
D liked your page
我所拥有的是6张桌子
table_users
table_posts
table_likes
table_shares
table_comments
table_community
每种类型的通知都遵循相同的模式
SELECT u.`name`, p.post, p.date as OrderDate
FROM likes (next shares, next, comments, community)
LEFT JOIN Users as u on likes.id_liker=u.id_user
LEFT JOIN Users as v on likes.liked_user_id=v.id_user
LEFT JOIN Posts as p on likes.liked_post_id=p.id_post
WHERE likes.liked_user_id=3
所以我使用UNION
排序的OrderDate
,他们检索结果但没有个性化的通知类型。我试图总结,因为这是巨大的。
答案 0 :(得分:0)
所以你想以不同方式格式化这些事件?这就像在输出中添加一个鉴别器字段一样简单
[-0.06326838 -0.09758444 0.06982093 0.01574633 0.0039237 0.07463291
0.02308519 0.04594345 0.07912541 0.00175323]
现在,在您的应用程序中,您可以根据第一列的值选择不同的格式。