在PHP中构建多通知系统的最佳方式 [英] Best Way To Build A Multi-Notification System in PHP

查看:119
本文介绍了在PHP中构建多通知系统的最佳方式的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我目前正在开发一款移动应用,可让您向朋友寻求收藏,它是一个HTML5前端和一个PHP后端。我遇到了什么最好的方法是建立一个通知系统,所以数据库模式比实际代码本身更多。

I am currently working on a mobile app that lets you ask friends for favourites, it's a HTML5 frontend and a PHP backend. I am stuck as to what the best way is to build a notifications system, more-so the database schema than the actual code itself.

移动应用程序流程如下


  • 用户要求支持

  • 用户可以选择;

  • 根据用户选择的内容,通知人们

在PHP和MySQL中最好的方法是什么?我不是真的要求任何人写我的PHP代码,而是映射出最理想的MySQL表和字段模式,而这是我目前困扰。感谢您的帮助。

What is the best way to do this in PHP and MySQL? I'm not really asking for anyone to write me the PHP code, but rather map out the most ideal MySQL table and fields schema instead as that is what I am currently stuck on. Thanks in advance for your help.

推荐答案

您可以创建一个通知表,例如:

You can create a notification table such as:

from_user | to_user | notification | seen

,然后每当你想通知用户你只需要添加一个记录, 看到 0 / false

and then whenever you want to notify a user you just add a record with the needed informations and set seen to 0 / false.

然后,当用户读取通知时,您将该参数设置为 1 / true

Then when the user reads the notification you set that parameter to 1 / true.

示例:

from_user | to_user | notification | seen
    -          -          -           -

用户john通知用户jeff:

User john notify user jeff:

from_user | to_user | notification | seen
   john      jeff       whatever..    0

用户jeff阅读通知:

User jeff read the notification:

from_user | to_user | notification | seen
   john      jeff       whatever..    1  

这篇关于在PHP中构建多通知系统的最佳方式的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆