PHP: using static tables for reference -- suggestions?

  • MacLuv
  • Novice
  • Novice
  • MacLuv
  • Posts: 19

Post 3+ Months Ago

Hi guys,

I'm using PHP/MySQL, and was wondering what the best way to do lookups with static tables would be. This would mean looking up values from tables that don't change, unlike database information which might change frequently.

Can you put a bunch of static tables in a PHP array or something? I'm new to PHP programming but learning quickly, any help or suggestions would be appreciated.

Also, if you need clarification to what I'm talking about, please feel free to ask.

Thanks in advance,

Johnny :)
  • Anonymous
  • Bot
  • No Avatar
  • Posts: ?
  • Loc: Ozzuland
  • Status: Online

Post 3+ Months Ago

  • b_heyer
  • Web Master
  • Web Master
  • User avatar
  • Posts: 4581
  • Loc: Maryland

Post 3+ Months Ago

I think you may be able to use multi-dimensional arrays ($array[0][0]).

Look here for help: http://www.php.net/manual/en/language.types.array.php

I suppose now that I think of it a normal array would work aswell, just lookover that page.
  • MacLuv
  • Novice
  • Novice
  • MacLuv
  • Posts: 19

Post 3+ Months Ago

b_heyer wrote:
I think you may be able to use multi-dimensional arrays ($array[0][0]).

Look here for help: http://www.php.net/manual/en/language.types.array.php

I suppose now that I think of it a normal array would work aswell, just lookover that page.


Thanks b, appreciate the input... do i have to destroy the array after making it if i don't need it anymore? (using unset)... what i mean is, if i'm just looking up a few bits of data in a function or something using an array, will that array take up heaps of memory or something? do i need to worry about that?

TIA

johnny :)
  • b_heyer
  • Web Master
  • Web Master
  • User avatar
  • Posts: 4581
  • Loc: Maryland

Post 3+ Months Ago

Hrmm, not that I know of. Do you not have access to a mysql database or something? I would recommend making it there just because it would be 10000 times easier.
  • MacLuv
  • Novice
  • Novice
  • MacLuv
  • Posts: 19

Post 3+ Months Ago

b_heyer wrote:
Hrmm, not that I know of. Do you not have access to a mysql database or something? I would recommend making it there just because it would be 10000 times easier.


hi b,

i've decided what i need to do is make all the static information into XML documents and then parse them with PHP into arrays when needed.... this way the static tables can also be used in other publications, etc... the thing is, i've known about this stuff for a long time now, i just never thought to use it in this project! (probably because parsing XML in PHP is a bit confusing at first, but I'll hopefully get the hang of it.)

Johnny :)
  • dr nick
  • Proficient
  • Proficient
  • dr nick
  • Posts: 263
  • Loc: Frankfurt

Post 3+ Months Ago

If you're concerned about the array taking up heaps of memory, I'm assuming you're looking at huge array sizes??? If you're managing lists that are, say, less than 1000 items long, then I think coding it into PHP wouldn't be such a problem if you're so inclined. But, if you're looking at more than that, then you're just going to be overloading your server because it would have to process the array each time the page is called. In this case, it would be MUCH better to store the info in an SQL database because its all called offline without the need to allocate the data each time...

Post Information

  • Total Posts in this topic: 6 posts
  • Users browsing this forum: No registered users and 115 guests
  • You cannot post new topics in this forum
  • You cannot reply to topics in this forum
  • You cannot edit your posts in this forum
  • You cannot delete your posts in this forum
  • You cannot post attachments in this forum
 
 

© 1998-2014. Ozzu® is a registered trademark of Unmelted, LLC.