Saving our data
Now if we could save our data, that would be great. We will be using the same database that we used in the last chapter. We can see this book's site at http://books.sosensible.com if we need to set up this database for practice. Let us look at the two ways in which a record is saved in ColdFusion. The first is how we would save a new record. This is called an INSERT
query:
<cfquery datasource="cfb" name="qryInsert"> INSERT INTO product( name , description , price)VALUES( <cfqueryparam value="#form.name#"> , <cfqueryparam value="#form.description#"> , <cfqueryparam value="#form.price#">) </cfquery>
Here, we see the basic code structure of an INSERT
query. We can see that the one thing different from the standard queries here is the VALUES
section. We have a new ColdFusion tag. The query param
tag <cfqueryparam>
is used to help make sure that a SQL injection is not used to attack your server. This tag provides additional functionality...