Results 1 to 2 of 2

Thread: Question about Serializing some Contact Form data

  1. #1
    Join Date
    Mar 2010

    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
    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?
    "Well done....Consciousness to sarcasm in five seconds!" ~ Terry Pratchett, Night Watch

    How to Ask Questions the Smart Way (not affiliated with this site, but well worth reading)

    My Blog
    cwrBlog: simple, no-database PHP blogging framework

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