vb.org Archive

vb.org Archive (https://vborg.vbsupport.ru/index.php)
-   vB3 Programming Discussions (https://vborg.vbsupport.ru/forumdisplay.php?f=15)
-   -   Associative arrays (https://vborg.vbsupport.ru/showthread.php?t=34636)

Jawelin 01-30-2002 06:14 PM

Hi. Where could I find an exaustive help with examples about multi-dimensional arrays ?
Actually I would - for a hack - store in memory some fields of a table of VB (user), to make some intensive operation without loading the db.
I thought a 2D array like this: $userArray[][]
Would use the two index, first as userid or other incremental value, second as the fields in the table.
For instance:

$userArray[][name]=$user[username]
$userArray[][mail]=$user[email]
... etc. in a cycle after a db fetch, but of course it doesn't work this way... ;)
Neither with an explicit first index as variable.

Do you have some example to load table in array with more values than the (key,value) as in php.net ?

Thanks a lot.
Bye

Mark Hensler 01-30-2002 10:30 PM

You do not want to do this. You will cram your RAM. (I made a rhym! ;))

It's better to build a query, then skip around the recordset using mysql_data_seek().

Admin 01-31-2002 08:54 AM

Where's the ryhm?

Jawelin 01-31-2002 09:17 AM

... cram .... RAM ... :greedy:

So it would be more efficient go back & forth through the recordset instead of loading data into Ram ?
Isn't it too heavy to mySQL engine ?

I should compare new users data with old ones.
If I had 'N' news (let's say 10 at a time) and 'T' total old users (let's say +3000...), the complexity of the check should be:
N*T = 30.000 seeks on DB !!!!
:noid:

Any idea ?

Thanks.

P.S.: and what about using mysql_fetch_array() or mysql_fetch_row() just after the seek ? Either which ?

Mark Hensler 01-31-2002 05:55 PM

I'm not sure about mySQL load for mysql_fetch_array() vs mysql_fetch_row(), but the fetch_array will take up more memory (not much).

What is the hack for?
How often will this be run?

How much data are you pulling from the DB?
Do you need to pull all the fields, or just a few?
Can you throw any of the logic at the DB or does it need to be done in PHP?

Compare this...
30,000 DB seeks
... or ...
30,000 * (number of fields) demensional array

Admin 02-01-2002 11:29 AM

That is the weakest rhyme I've ever heard. ;)

Mark Hensler 02-01-2002 02:36 PM

*sigh* well, I tried :(

Jawelin 02-01-2002 03:50 PM

Quote:

Originally posted by Mark Hensler
I'm not sure about mySQL load for mysql_fetch_array() vs mysql_fetch_row(), but the fetch_array will take up more memory (not much).

What is the hack for?
How often will this be run?
[...]

Well. I was trying to do myself an enhanced user moderation queue, mainly to findout potential dupe users when moderating new ones.
You can check here the original input, but would try to solve myself as far as i could.

By now I added a new action to admin/user.php like 'finddupe', called from the user moderation page.

Actually I would need to load in memory almost 3-4 columns of the user table as I should compare the single metaphone() each others, measuring the levenshtein() distance between, for example, usernames/emails/ips/password-md5-hash (identical, of course), and so on.
This reason I though to memory as mySQL couldn't do anything itself.

Frequency: well, about once/twice a day, the times I moderate new users...
Do you think an array like this should overload the system ?

P.S.: anyway, any 2D arrays example ??? :supwink:

Thanks, poet!!! :china:

Mark Hensler 02-01-2002 09:01 PM

Why are your that paranoid? That seems like overkill. :rolleyes:

Anyway.. Your right, you couldn't do this in mySQL. I've never loaded an array of that size. I'm not sure what that would do to your system. :confused:

Some thoughts...
You don't have to calculate the metaphone() for each search. Instead, calculate it once for all existing users, and when new users register. Store the value in another field in the DB. Then you could use a simple query to test the metaphone() for new users.

The levenshtein is trickier, as you can't preproccess anything and store it in the DB.

What did you want to do to the IP? levenshtein()? You may be able to do something similar by using wildcards in mySQL. For example, most dialups will only vary in the last 2 octets.


Just some thoughts.

Jawelin 02-01-2002 09:13 PM

They are all parameters that - took together - can build a complex profile about a dupe user.

Paranoid? Yeah! I saw for months people subscribing again and again just because they wouldn't remember the password...
I explained well talking about the hack I linked to above.
Thanks, hwr.


All times are GMT. The time now is 02:24 AM.

Powered by vBulletin® Version 3.8.12 by vBS
Copyright ©2000 - 2025, vBulletin Solutions Inc.

X vBulletin 3.8.12 by vBS Debug Information
  • Page Generation 0.01042 seconds
  • Memory Usage 1,732KB
  • Queries Executed 10 (?)
More Information
Template Usage:
  • (1)ad_footer_end
  • (1)ad_footer_start
  • (1)ad_header_end
  • (1)ad_header_logo
  • (1)ad_navbar_below
  • (1)bbcode_quote_printable
  • (1)footer
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (6)option
  • (1)post_thanks_navbar_search
  • (1)printthread
  • (10)printthreadbit
  • (1)spacer_close
  • (1)spacer_open 

Phrase Groups Available:
  • global
  • postbit
  • showthread
Included Files:
  • ./printthread.php
  • ./global.php
  • ./includes/init.php
  • ./includes/class_core.php
  • ./includes/config.php
  • ./includes/functions.php
  • ./includes/class_hook.php
  • ./includes/modsystem_functions.php
  • ./includes/class_bbcode_alt.php
  • ./includes/class_bbcode.php
  • ./includes/functions_bigthree.php 

Hooks Called:
  • init_startup
  • init_startup_session_setup_start
  • init_startup_session_setup_complete
  • cache_permissions
  • fetch_threadinfo_query
  • fetch_threadinfo
  • fetch_foruminfo
  • style_fetch
  • cache_templates
  • global_start
  • parse_templates
  • global_setup_complete
  • printthread_start
  • bbcode_fetch_tags
  • bbcode_create
  • bbcode_parse_start
  • bbcode_parse_complete_precache
  • bbcode_parse_complete
  • printthread_post
  • printthread_complete