在 php 中存储好友列表的最佳方法是什么?

发布于 2025-01-08 12:52:31 字数 366 浏览 0 评论 0原文

为了在我的网页中实现好友列表方法,

在 php 中存储好友列表的最佳方式是什么?

我的选项是

数据库 请参见此链接

创建每个用户都有单独的文件夹存储一个 xml 文件,其中包含该用户的好友列表。

请给我推荐最好的一个吗?

如果有人有其他逻辑,请告诉我。

In order to implement friends list method in my webpage,

Which is the best way to store friends list in php?

My options are

Database See this Link

or

create a separate folder for each user and store an xml file which contains that user's friendslist.

Please do suggest me the best one?

If anyone has other logic.let me know about it.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

咆哮 2025-01-15 12:52:31

我会推荐该数据库选项,如您问题中的链接所述。特别是,用户表与关系表分开的数据库模式。您会发现删除好友之类的事情变得更加容易和高效。

I would recommend that database option, as described in the link in your question. In particular, the database schema in which the users table is separate from the relationship table. You'll find things like deleting friendships much easier and more efficient.

落叶缤纷 2025-01-15 12:52:31

您肯定想给出更好的“最佳”标准——性能、可维护性、可扩展性、灵活性?

您还可以通过解释您打算如何使用这些朋友列表来帮助我们 - 这使我们能够了解这些建议是否有意义。

话虽如此......

我会推荐一个数据库。这样,您可以存储关系并可以在一个地方对其进行推理 - 例如,您可以查明爱丽丝是否是鲍勃的朋友,以及鲍勃是否是爱丽丝的朋友(在文本文件方案中,您必须将此信息存储在“Alice”和“Bob”文本文件中,这使得检查很痛苦,尤其是对于一大群人来说)。

您还可以轻松找到朋友链,这样您就可以推荐朋友(如果Alice是Bob和Chuck的朋友,她可能认识其他与Bob和Chuck都是朋友的人)。

最后,您可以获得数据库的其他好处 - 处理多个并发用户时的性能、ACID 等。

You definitely want to give better criteria for "best" - performance, maintainability, scalability, flexibility?

You also would help us by explaining how you intend to use those friend lists - that allows us to see if the proposals make sense.

Having said that....

I'd recommend a database. That way, you store the relationship and can reason about it in a single place - for instance, you can find out if Alice is friends with Bob, and whether Bob is friends with Alice (in the text file scheme, you'd have to store this information in the "Alice" and "Bob" text files, which makes checking a pain, especially for large groups of people).

You can also easily find friend chains, so you can suggest friends (if Alice is friends with Bob and Chuck, she may know other people who are friends with both Bob and Chuck).

Finally, you get the other benefits of databases - performance when dealing with multiple concurrent users, ACID etc.

心如荒岛 2025-01-15 12:52:31

对于这样的小型作业,我建议使用 SQLLIte 或文本文件。

I can recommend to use SQLLIte or text files for small jobs like this.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文