www.webdeveloper.com
Results 1 to 2 of 2

Thread: Question about Serializing some Contact Form data

  1. #1
    Join Date
    Mar 2010
    Posts
    281

    Question about Serializing some Contact Form data

    I have a question about serialization and using with a MySQL DB.

    i have contact form data being collected and have serialized using jQuery serialize() method.

    I serialized partly as an excercise but also because someone here on this list recommended it,maybe i shouldn't serialize?!

    The data is only 7 fields of text input, typical stuff, firstname, lastname, company, email etc.

    Typically what happens to serialized data such as above? would it be put into a single cell?, or separated out into multiple columns?, why do it in the first place?, maybe i shouldn't serialize at all?

    any advice would be very much appreciated.

  2. #2
    Join Date
    Aug 2004
    Location
    Ankh-Morpork
    Posts
    18,925
    The only reason (DB-wise) to serialize it is if you in fact want to store it all in one field (probably a TEXT field in MySQL). Normally I would only do this for data that might have a variable structure, such that you cannot say from instance to instance what "columns" need to be defined to hold it; and in doing so you are willing to give up any reasonable ability to search/sort that data via the database itself. Where I've mainly seen it used is for using a database to store PHP session data (instead of file system storage), whereby you can simply serialize the $_SESSION array and store the result in on text column (with other columns for session ID, timestamp, etc.).

    In your example, however, it seems like you know what the data structure will be, which sounds like it should have a corresponding table in the DB with that structure, and thus no need to serialize it -- unless I'm missing something?
    "Please give us a simple answer, so that we don't have to think, because if we think, we might find answers that don't fit the way we want the world to be."
    ~ Terry Pratchett in Nation

    eBookworm.us

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center



Recent Articles