Go Back   vb.org Archive > vBulletin 3 Discussion > vB3 Programming Discussions
  #1  
Old 01-30-2002, 06:14 PM
Jawelin Jawelin is offline
 
Join Date: Nov 2001
Posts: 557
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

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
Reply With Quote
  #2  
Old 01-30-2002, 10:30 PM
Mark Hensler's Avatar
Mark Hensler Mark Hensler is offline
 
Join Date: Oct 2001
Location: California
Posts: 205
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

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().
Reply With Quote
  #3  
Old 01-31-2002, 08:54 AM
Admin's Avatar
Admin Admin is offline
Coder
 
Join Date: Oct 2023
Location: Server
Posts: 1
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Where's the ryhm?
Reply With Quote
  #4  
Old 01-31-2002, 09:17 AM
Jawelin Jawelin is offline
 
Join Date: Nov 2001
Posts: 557
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

... 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 ?
Reply With Quote
  #5  
Old 01-31-2002, 05:55 PM
Mark Hensler's Avatar
Mark Hensler Mark Hensler is offline
 
Join Date: Oct 2001
Location: California
Posts: 205
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

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
Reply With Quote
  #6  
Old 02-01-2002, 11:29 AM
Admin's Avatar
Admin Admin is offline
Coder
 
Join Date: Oct 2023
Location: Server
Posts: 1
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

That is the weakest rhyme I've ever heard.
Reply With Quote
  #7  
Old 02-01-2002, 02:36 PM
Mark Hensler's Avatar
Mark Hensler Mark Hensler is offline
 
Join Date: Oct 2001
Location: California
Posts: 205
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

*sigh* well, I tried
Reply With Quote
  #8  
Old 02-01-2002, 03:50 PM
Jawelin Jawelin is offline
 
Join Date: Nov 2001
Posts: 557
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

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:
Reply With Quote
  #9  
Old 02-01-2002, 09:01 PM
Mark Hensler's Avatar
Mark Hensler Mark Hensler is offline
 
Join Date: Oct 2001
Location: California
Posts: 205
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Why are your that paranoid? That seems like overkill.

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.

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.
Reply With Quote
  #10  
Old 02-01-2002, 09:13 PM
Jawelin Jawelin is offline
 
Join Date: Nov 2001
Posts: 557
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

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.
Reply With Quote
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT. The time now is 11:33 PM.


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.07138 seconds
  • Memory Usage 2,244KB
  • Queries Executed 11 (?)
More Information
Template Usage:
  • (1)SHOWTHREAD
  • (1)ad_footer_end
  • (1)ad_footer_start
  • (1)ad_header_end
  • (1)ad_header_logo
  • (1)ad_navbar_below
  • (1)ad_showthread_beforeqr
  • (1)ad_showthread_firstpost
  • (1)ad_showthread_firstpost_sig
  • (1)ad_showthread_firstpost_start
  • (1)bbcode_quote
  • (1)footer
  • (1)forumjump
  • (1)forumrules
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (1)navbar
  • (3)navbar_link
  • (120)option
  • (10)post_thanks_box
  • (10)post_thanks_button
  • (1)post_thanks_javascript
  • (1)post_thanks_navbar_search
  • (10)post_thanks_postbit_info
  • (10)postbit
  • (10)postbit_onlinestatus
  • (10)postbit_wrapper
  • (1)spacer_close
  • (1)spacer_open
  • (1)tagbit_wrapper 

Phrase Groups Available:
  • global
  • inlinemod
  • postbit
  • posting
  • reputationlevel
  • showthread
Included Files:
  • ./showthread.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/functions_bigthree.php
  • ./includes/class_postbit.php
  • ./includes/class_bbcode.php
  • ./includes/functions_reputation.php
  • ./includes/functions_post_thanks.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
  • showthread_start
  • showthread_getinfo
  • forumjump
  • showthread_post_start
  • showthread_query_postids
  • showthread_query
  • bbcode_fetch_tags
  • bbcode_create
  • showthread_postbit_create
  • postbit_factory
  • postbit_display_start
  • post_thanks_function_post_thanks_off_start
  • post_thanks_function_post_thanks_off_end
  • post_thanks_function_fetch_thanks_start
  • post_thanks_function_fetch_thanks_end
  • post_thanks_function_thanked_already_start
  • post_thanks_function_thanked_already_end
  • fetch_musername
  • postbit_imicons
  • bbcode_parse_start
  • bbcode_parse_complete_precache
  • bbcode_parse_complete
  • postbit_display_complete
  • post_thanks_function_can_thank_this_post_start
  • tag_fetchbit_complete
  • forumrules
  • navbits
  • navbits_complete
  • showthread_complete