personally, because I hate typing all those getAttributeX() calls I
do one getMemento call then just reference the struct variables in the
query.
<cfset var details = arguments.contactDetails.getMemento() />
<cfquery name="updateContactDetails" datasource="#variables.DSN#">
UPDATE tbl_EBR_Institution
SET Institution_Address1 = '#details.address1#',
Institution_Address2 = '#details.address2#',
Institution_Address3 = '#details.address3#',
Institution_Address4 = '#details.address4#',
Institution_PostCode = '#details.postcode#',
Name_of_head = '#details.headName#',
TelNo_of_head = '#details.headTelNo#',
FaxNo_of_head = '#details.headFaxNo#',
Email_of_head = '#details.headEmail#'
WHERE DRB_Number = '#details.DRBNumber#'
</cfquery>
I would also update that query to use <cfqueryparam .. like so:
<cfquery name="updateContactDetails" datasource="#variables.DSN#">
UPDATE tbl_EBR_Institution
SET Institution_Address1 = <cfqueryparam
cfsqltype="cf_sql_varchar" value="#details.address1#" />,
...
WHERE DRB_Number = <cfqueryparam
cfsqltype="cf_sql_varchar" value="#details.DRBNumber#" />
</cfquery>
using the cfqueryparam will help with both performance and,
supposedly, sql injection attacks.
Bill
On 9/22/05, Stephen Adams <[EMAIL PROTECTED]> wrote:
> Yes it is, I've been using CFDUMP to output the data, seems to work.
>
> On 22/09/05, Nando <[EMAIL PROTECTED] > wrote:
> >
> > Stephan,
> >
> > Have you figured out how to debug / dump stuff from within CFC's so you
> can see what's going on?
> >
> > Is this a numeric field?
> >
> > WHERE DRB_Number =
> '#arguments.contactDetails.GetDRBNumber()#'
> >
> >
> > -----Original Message-----
> > From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] Behalf
> Of Stephen Adams
> >
> > Sent: Thursday, September 22, 2005 4:04 PM
> > To: [email protected]
> > Subject: Re: [CFCDev] How to find out information about the type of object
> you are using.
> >
> >
> > Yes I've amended my query to look like this:
> >
> > <cfquery name="updateContactDetails" datasource="#variables.DSN#">
> > UPDATE tbl_EBR_Institution
> > SET Institution_Address1 =
> '#arguments.contactDetails.GetAddress1()#',
> > Institution_Address2 =
> '#arguments.contactDetails.GetAddress2()#',
> > Institution_Address3 =
> '#arguments.contactDetails.GetAddress3()#',
> > Institution_Address4 =
> '#arguments.contactDetails.GetAddress4()#',
> > Institution_PostCode =
> '#arguments.contactDetails.GetPostcode()#',
> > Name_of_head =
> '#arguments.contactDetails.GetHeadName()#',
> > TelNo_of_head =
> '#arguments.contactDetails.GetHeadTelNo()#',
> > FaxNo_of_head =
> '#arguments.contactDetails.GetHeadFaxNo()#',
> > Email_of_head =
> '#arguments.contactDetails.GetHeadEmail()#'
> > WHERE DRB_Number =
> '#arguments.contactDetails.GetDRBNumber()#'
> > </cfquery>
> >
> > Still not updating the record.
> >
> >
> > On 22/09/05, RADEMAKERS Tanguy <[EMAIL PROTECTED]> wrote:
> > >
> > > do you get an error message from your db or do you get no error but
> nothing is updated? Have you tried scoping the variables in the cfquery
> like:
> > >
> > > Address1 = '#arguments.contactDetails.GetAddress1()#',
> > >
> > > /t
> > >
> > >
> > > ________________________________
> From: [EMAIL PROTECTED] [mailto: [EMAIL PROTECTED] On Behalf
> Of Stephen Adams
> > > Sent: Thursday, September 22, 2005 2:52 PM
> > > To: [email protected]
> > > Subject: Re: [CFCDev] How to find out information about the type of
> object you are using.
> > >
> > >
> > > Yes I just did, that worked, but now the update query does not seem to
> be updating even the values are being set in the Bean, and I can access them
> using the Get methods. I'm going to look at the Debug and see if the SQL is
> workign correctly.
> > >
> > > Slowly getting there, thanks for the help.
> > >
> > >
> > > On 22/09/05, RADEMAKERS Tanguy < [EMAIL PROTECTED] > wrote:
> > > >
> > > > just thinking out loud - have you tried
> > > >
> > > > <cfargument name="contactDetails"
> type="Helpdesk_dev.cfc.Beans.ContactDetailsBean"
> required="true" />
> > > >
> > > >
> > > > /t
> > > >
> > > >
> > > >
> > > >
> > > > ________________________________
>
> > > > From: [EMAIL PROTECTED] [mailto: [EMAIL PROTECTED] On
> Behalf Of Stephen Adams
> > > > Sent: Thursday, September 22, 2005 2:30 PM
> > > > To: [email protected]
> > > > Subject: [CFCDev] How to find out information about the type of object
> you are using.
> > > >
> > > >
> > > >
> > > >
> > > > Hi all,
> > > >
> > > > I'm trying to use a DAO component and a Bean to update details
> submitted by a form. I'm tryng to use the method that Joe Reinhart set out
> in his blog (
> http://clearsoftware.net/client/index.cfm?mode=entry&entry=3D1115E7-E081-2BAC-6953DA4394855DDB
> ) where you use a Bean to gather all the form fields together, then pass the
> Bean object to DAO object, and the update query.
> > > >
> > > > Unfortunately everytime I pass my Bean to the DAO object I get an
> error message telling me that it's not an object type of my Bean! Is there
> anyway I can check, what my Bean object contains and what type it is.
> > > >
> > > > Here's what my code looks like:
> > > >
> > > > contactDetails = createObject("component",
> "Helpdesk_dev.cfc.Beans.ContactDetailsBean");
> > > > contactDetails.SetDRBNumber('#FORM.txtDRBNumber#');
> > > > contactDetails.SetDRBName('#FORM.txtDRBName#');
> > > > contactDetails.SetAddress1('#FORM.txtAddress1#');
> > > > contactDetails.SetAddress2('#FORM.txtAddress2#');
> > > > contactDetails.SetAddress3('#FORM.txtAddress3#');
> > > > contactDetails.SetAddress4('#FORM.txtTown#');
> > > > contactDetails.SetPostcode('#FORM.txtPostcode#');
> > > > contactDetails.SetHeadName ('#FORM.txtContactName#');
> > > > contactDetails.SetHeadTelNo('#FORM.txtContactTel#');
> > > > contactDetails.SetHeadFaxNo('#FORM.txtContactFax#');
> > > > contactDetails.SetHeadEmail('#FORM.txtContactEmail#');
> > > >
> > > > // pass Bean containing form field details to update method
> > > > objContactDetails = createObject("component",
> "Helpdesk_dev.cfc.DAO.DrbDAO").init(#application.DSN#);
> > > > updatedContactDetails = objContactDetails.update(contactDetails);
> > > >
> > > > Then the update method from the DAO bean looks like this:
> > > >
> > > > <cffunction name="update" access="public" returntype="struct"
> output="false">
> > > > <cfargument name="contactDetails" type="ContactDetailsBean"
> required="true" />
> > > >
> > > > <cfquery name="updateContactDetails"
> datasource="#variables.DSN#">
> > > > UPDATE tbl_Contact_details
> > > > SET Address1 =
> '#contactDetails.GetAddress1()#',
> > > > Address2 =
> '#contactDetails.GetAddress2()#',
> > > > Address3 =
> '#contactDetails.GetAddress3()#',
> > > > Address4 =
> '#contactDetails.GetAddress4()#',
> > > > PostCode =
> '#contactDetails.GetPostcode()#',
> > > > Name_of_head =
> '#contactDetails.GetHeadName()#',
> > > > TelNo_of_head =
> '#contactDetails.GetHeadTelNo()#',
> > > > FaxNo_of_head =
> '#contactDetails.GetHeadFaxNo()#',
> > > > Email_of_head =
> '#contactDetails.GetHeadEmail()#'
> > > > WHERE DRB_Number =
> '#contactDetails.GetDRBNumber()#'
> > > > </cfquery>
> > > >
> > > > </cffunction>
> > > >
> > > > I'm stumped by this?
> > > >
> > > > Stephen
> > > >
> ----------------------------------------------------------
> > > > You are subscribed to cfcdev. To unsubscribe, send an email to
> [email protected] with the words 'unsubscribe cfcdev' as the subject of the
> email.
> > > >
> > > > CFCDev is run by CFCZone (www.cfczone.org) and supported by CFXHosting
> (www.cfxhosting.com).
> > > >
> > > > CFCDev is supported by New Atlanta, makers of BlueDragon
> > > >
> http://www.newatlanta.com/products/bluedragon/index.cfm
> > > >
> > > > An archive of the CFCDev list is available at
> www.mail-archive.com/[email protected]
> > > >
> ----------------------------------------------------------
> > > > You are subscribed to cfcdev. To unsubscribe, send an email to
> [email protected] with the words 'unsubscribe cfcdev' as the subject of the
> email.
> > > >
> > > > CFCDev is run by CFCZone ( www.cfczone.org) and supported by
> CFXHosting (www.cfxhosting.com).
> > > >
> > > > CFCDev is supported by New Atlanta, makers of BlueDragon
> > > >
> http://www.newatlanta.com/products/bluedragon/index.cfm
> > > >
> > > > An archive of the CFCDev list is available at
> www.mail-archive.com/[email protected]
> > >
> > >
> > >
> ----------------------------------------------------------
> > > You are subscribed to cfcdev. To unsubscribe, send an email to
> [email protected] with the words 'unsubscribe cfcdev' as the subject of the
> email.
> > >
> > > CFCDev is run by CFCZone (www.cfczone.org) and supported by CFXHosting
> (www.cfxhosting.com).
> > >
> > > CFCDev is supported by New Atlanta, makers of BlueDragon
> > > http://www.newatlanta.com/products/bluedragon/index.cfm
> > >
> > > An archive of the CFCDev list is available at
> www.mail-archive.com/[email protected]
> > >
> ----------------------------------------------------------
> > > You are subscribed to cfcdev. To unsubscribe, send an email to
> [email protected] with the words 'unsubscribe cfcdev' as the subject of the
> email.
> > >
> > > CFCDev is run by CFCZone ( www.cfczone.org) and supported by CFXHosting
> (www.cfxhosting.com).
> > >
> > > CFCDev is supported by New Atlanta, makers of BlueDragon
> > > http://www.newatlanta.com/products/bluedragon/index.cfm
> > >
> > > An archive of the CFCDev list is available at
> www.mail-archive.com/[email protected]
> >
> >
> ----------------------------------------------------------
> > You are subscribed to cfcdev. To unsubscribe, send an email to
> [email protected] with the words 'unsubscribe cfcdev' as the subject of the
> email.
> >
> > CFCDev is run by CFCZone (www.cfczone.org) and supported by CFXHosting
> (www.cfxhosting.com).
> >
> > CFCDev is supported by New Atlanta, makers of BlueDragon
> > http://www.newatlanta.com/products/bluedragon/index.cfm
> >
> > An archive of the CFCDev list is available at
> www.mail-archive.com/[email protected]
> >
> ----------------------------------------------------------
> > You are subscribed to cfcdev. To unsubscribe, send an email to
> [email protected] with the words 'unsubscribe cfcdev' as the subject of the
> email.
> >
> > CFCDev is run by CFCZone (www.cfczone.org) and supported by CFXHosting (
> www.cfxhosting.com).
> >
> > CFCDev is supported by New Atlanta, makers of BlueDragon
> > http://www.newatlanta.com/products/bluedragon/index.cfm
> >
> > An archive of the CFCDev list is available at
> www.mail-archive.com/[email protected]
>
> ----------------------------------------------------------
> You are subscribed to cfcdev. To unsubscribe, send an email to
> [email protected] with the words 'unsubscribe cfcdev' as the subject of the
> email.
>
> CFCDev is run by CFCZone (www.cfczone.org) and supported by CFXHosting
> (www.cfxhosting.com).
>
> CFCDev is supported by New Atlanta, makers of BlueDragon
> http://www.newatlanta.com/products/bluedragon/index.cfm
>
> An archive of the CFCDev list is available at
> www.mail-archive.com/[email protected]
--
[EMAIL PROTECTED]
http://blog.rawlinson.us
If you want Gmail - just ask.
----------------------------------------------------------
You are subscribed to cfcdev. To unsubscribe, send an email to
[email protected] with the words 'unsubscribe cfcdev' as the subject of the
email.
CFCDev is run by CFCZone (www.cfczone.org) and supported by CFXHosting
(www.cfxhosting.com).
CFCDev is supported by New Atlanta, makers of BlueDragon
http://www.newatlanta.com/products/bluedragon/index.cfm
An archive of the CFCDev list is available at
www.mail-archive.com/[email protected]