有关获取用户信息的建议

有关获取用户信息的建议

本文介绍了有关获取用户信息的建议的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

所以,我有自己开发的内容管理系统。

系统有一个坚实的社区部分,会员可以注册然后

参与论坛,写博客和其他很多东西。


因此,在我列出的例子中,例如最新的博客。我列出了

博客的标题,成员的日期和名称

写的。


现在,这个名字不仅仅是史密斯,而是史密斯的在线状态,

他的昵称和他的标签,并且看起来像这样:


< imageSmith M:34(新手)


图像是描绘其在线状态的绿点或红点。

我想显示这个,我用这个函数:


print member_name(12);


12是史密斯的id号,关于博客作者的唯一信息

(即我不会在

博客帖子中保存他的昵称或标签,当然不是他的在线状态) 。


所以,当使用member_name()时,我在一个预取的数组中查找id 12

的成员,显示正确的信息。紧凑格式:


## index.php

require_once(" member.php");

print member_name (12);


## member.php

$ q = mysql_query(" select id,name,members from members");

while($ r = mysql_fetch_assoc($ q)){

$ GLOBALS [" members"] [$ r [" id"]] = $ r;

}


函数member_name($ id){

$ m = $ GLOBALS [" members"] [$ id];

$ online = in_array($ id,$ GLOBALS [" surfers"])? "上" :" off";

返回图标(在线/ $ online)。 " $ m [name] $ m [label]" ;;

}


##


所以,每当需要member.php时,所有成员都被预取并将

放入$ GLOBALS [" member"],这已经很好用了。然后我用指尖轻触任何给定会员的信息。


但现在我有一些网站开始变得非常大了

会员数量,所以预取它们都会耗费时间

(有时长达一秒钟,这是慢得令人无法接受的)。


我可以'在

显示他或她的信息时,不会获取有关每个人的信息,因为可能有很长的名单用于

示例博客,并且可能有40-50要显示的成员名称,

会导致40-50个单独的mysql请求,这会淹没MySSQL服务器的b $ b,我很害怕。

所以,我的问题是这个;我可以用其他什么方式做到这一点?是否有更快的方式来读取数千甚至数万个信息

积分并快速将它们放入阵列?


或者有没有更好的方法来阅读有关单个成员的信息?

运行时间?


聚合肯定是一种选择。我可以写一个分隔

文本文件的标签,并在member.txt中读取它 - 它会更快吗?应该

每个用户写一个文本文件并在需要时读取该文件?


任何人都有这方面的经验吗?你是怎么解决的?


提前谢谢。 :)


-

Sandman [.net]

So, I have this content management system I''ve developed myself. The
system has a solid community part where members can register and then
participate in forums, write weblogs and a ton of other things.

So, in instances where I list, for example, the latest weblogs. I list
the headline of the weblog, the date and the name of the member who
wrote it.

Now, the name isn''t just "Smith", but rather Smith''s online status,
his nick and his "label", and can look like this:

<imageSmith M:34 (Newbie)

The image is either a green or red dot depicting his online status.
When I want to display this, I use this function:

print member_name(12);

With 12 being the id number of Smith, and the only information about
the writer of the weblog (i.e. I don''t save his nick or label in the
weblog post, and certainly not his online status).

So, when using member_name() I look up the id 12 in a prefetched array
of members, displaying the correct information. In a compact format:

## index.php
require_once("member.php");
print member_name(12);

## member.php
$q=mysql_query("select id, name, label from members");
while ($r=mysql_fetch_assoc($q)){
$GLOBALS["members"][$r["id"]] = $r;
}

function member_name($id){
$m = $GLOBALS["members"][$id];
$online = in_array($id, $GLOBALS["surfers"]) ? "on" : "off";
return icon("online/$online") . " $m[name] $m[label]";
}

##

So, whenever requiring member.php, all members are prefetched and put
into $GLOBALS["members"], which has worked just fine. Then I have
infromation about any given member at my fingertips.

But now I have some sites which are beginning to get a pretty large
number of members, so prefetching them all becomes timeconsuming
(sometimes up to one second, which is unacceptably slow).

I can''t fetch information about each single individual at the point of
showin his or hers information since there can be long lists of for
example weblogs and there might be 40-50 member names to be shown,
which would result in 40-50 seperate mysql requests, which would flood
the MySSQL server, I''m afraid.
So, my question is this; what other way can I do this in? Is there a
faster way to read thousands or even tens of thousands of information
points and put them in an array quickly?

Or is there a better way to read information about single members at
runtime?

Aggregation is most certainly an option. Can I write a tab separated
text file and read that one in member.txt - would it be faster? Should
I write one text file per user and read that file when needed?

Anyone got any experience in doing this? How did you solve it?

Thanks in advance. :)


--
Sandman[.net]

推荐答案




这篇关于有关获取用户信息的建议的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

07-29 23:20