从SQL数据库进入数组的更快捷方式 [英] faster way to get from SQL database into array

查看:55
本文介绍了从SQL数据库进入数组的更快捷方式的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我目前有一个md5字符串列表,需要检查该列表中是否有新的

字符串数十万次。我发现

最快的方法是将所有md5存储在一个数组中,并使用php函数in_array()。

我现在唯一的问题是用我的sql

服务器的数据填充这个数组是相当慢的,我目前使用的是:


$ resone = mysql_query(" SELECT * FROM logs_full");

mysql_close();


while($ row = mysql_fetch_array($ resone) )){

$ md5array [$ md5count] = $ row [''textmd5''];

$ md5count ++;

}


这样做。有人有更快的方法吗?

I currently have a list of md5 strings and need to check if a new
string is in that list hundreds of thousands of times. I''ve found that
the fastest way to do this is to have all the md5''s stored in an array
and use the php function in_array().
my only problem now is that populating this array with data from my sql
server is rather slow, I currently use the lines:

$resone = mysql_query("SELECT * FROM logs_full");
mysql_close();

while ($row = mysql_fetch_array($resone)) {
$md5array[$md5count]= $row[''textmd5''];
$md5count++;
}

to do this. does anyone have a faster method?

推荐答案

resone = mysql_query(" SELECT * FROM logs_full");

mysql_close();


while(
resone = mysql_query("SELECT * FROM logs_full");
mysql_close();

while (


row = mysql_fetch_array(
row = mysql_fetch_array(


resone)) {
resone)) {


这篇关于从SQL数据库进入数组的更快捷方式的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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