Jump to content


Prefered Method: Storing Arrays


2 replies to this topic

#1 .CJ

    Young Padawan

  • Members
  • Pip
  • 114 posts
  • Gender:Male
  • Location:Leeds, UK

Posted 20 July 2007 - 09:27 PM

Hello all,

Potential discussion here. From what I've read around the Internet, storing arrays can be done in a number of ways; two of the only ways I know how are by using serialize and unserialize and also using implode and explode functions. I'm going to begin development on a website soon and will be storing arrays in a database. When I looked up how to go about doing this, I saw the two methods I mentioned above and even tried them out, with success on each attempt.

My question is, what are your preferred methods of storing arrays in a database. I ask out of curiosity, as I've seen there are some great coders among this website and each coder has there own way of setting up there code.

Look forward to hearing from you about this, also if you have any code examples, show it! :)

Thanks,

Chris.

#2 Demonslay

    P2L Jedi

  • Members
  • PipPipPip
  • 970 posts
  • Gender:Male
  • Location:A strange world where water falls out of the sky... for no reason.
  • Interests:Graphic Design, Coding, Splinter Cell, Cats

Posted 20 July 2007 - 11:40 PM

There is really no 'correct' way, it is all a matter of preference.

Storing with deliminators and using implode() and explode() would use less space, as serialize(), well, serializes the array and gives strings telling what the key indexes, type, and length are and such.

I can't really say why, but I personally use the serialize method, as it just seems a tad more professional to me, lol.

#3 rc69

    PHP Master PD

  • P2L Staff
  • PipPipPipPip
  • 3,827 posts
  • Gender:Male
  • Location:Here
  • Interests:Web Development

Posted 21 July 2007 - 02:44 AM

I simply don't store arrays. Never found the need to. If i had to, i'd most likely use serialize() for how simple it is, evetually get annoyed with how long the result ends up being, and evetually break it down to a CSV file... Depends on the use i guess.





1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users