Background: I am going to save my ColdFusion forms data into an array and store that array into the column of a database. The only thing I will be doing with this array is making a call to the database for the data and parsing it back into my form but as "Read Only". The array will contain both the input name and value.
Question: In ColdFusion after I have queried the database for the array data what would be the best process to parse the data back into my form? Do I have to recreate my form in a loop? Or can I target the inputs and and add the values since I will know their names?
Also is there any value in saving the data as serialized JSON data verse an array created with ColdFusion?
****EDIT***
Below is an outline of the workflow of my data. Some of these items where requested by the client.
User completes form with 65 inputs.
On Submit all of the form data is stored in an array which is added to a database. The database also has the following data added. A unique numerical identifier, Submission Date, User ID that submitted the form (pulled from a Session variable), and finally a status of "not assigned" is added to the database
An admin checks a queue on a separate page. That queue simple pulls all form submissions that are still in "not assigned" status. The array is not used in this queue.
If an admin selects one of the entries in the queue the following page loads the exact same form but I will use the array to populate the values into the form and set all fields to read only. The admin literally only needs to copy and paste the values from the form fields into a different system. (Yes I know it sounds tedious but for this specific client there is no other option and this is actually better than the process they are currently using.)
The array data will literally never be used for anything else other than to make sure all of the data is collected.
The array data will always have to be loaded as a whole and will never be changed once submitted.
I hope this helps clear up why I am asking these questions. THanks
First, what pankaj means.
You can do something like this. Let's say I'm storing preferential aspects of a car. 1997 Honda Accord. You might store data in about it like this.
Cars Table
And then I can have a separate table called CarSpecs
You could store (Make, Model, Year) in this table as well, but let's say you didn't.
You're insertion becomes something like this..
(If you're not using cfqueryparam, please look it up, it protects against sql injection, a common form of hacking.)
There are a few easy ways to get the id of the record you just inserted (
#NewCar.generatedkey#
). Here's a short article on it if you're unfamiliar.Now, as we covered in the comments on your previous question
The best way is inserting into separate rows as I've demostrated. Following that, separate columns would be better than inserting as a bulk.
The only benefit to inserting as a bulk is it's easy, that's it.
The downsides, however, are numerous.
To select any of the data, you have to either
Intertable queries (joins) based on this field are going to be a huge headache.
So suppose you devised something like my example above. You could select all the details for a car like this.