Nando, Thank you for this tip. It pushed me a bit further towards my goal. Unfortunately, when I got to update function, it said this:
<cfquery> <!--- Update the table with values from getter methods ---> </cfquery> So this page has everything except for the SQL stmt itself, which was the point of my original post. --- I've learned a lot from it though! --- I created a Users table to try his example, but there's a lot missing, particularly in the calling form. (If you try to edit a user, it adds a new one instead). I've posted a comment to the blog asking the author to complete his example by providing an update and delete feature. -----Original Message----- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Nando Sent: Friday, December 02, 2005 6:46 PM To: [email protected] Subject: RE: [CFCDev] Object Oriented updating When Matt is saying at the end of his post, "You could, but you probably wouldn't want to" - it's similar to saying you could do this: Update Book SET Title='OO baby' WHERE BookID=7 Update Book SET NumberofPages=3 WHERE BookID=7 But probably wouldn't want to. I can highly recommend Joe Reinhart's excellent DAO tutorials. mind the wrap ... http://clearsoftware.net/client/index.cfm?mode=entry&entry=3D1115E7-E081-2BA C-6953DA4394855DDB Search his site for anything related to OO. He's a good writer. >-----Original Message----- >From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] >Behalf Of Matt Woodward >Sent: Saturday, December 03, 2005 12:18 AM >To: [email protected] >Subject: Re: [CFCDev] Object Oriented updating > > >On 12/2/05, Phillip Senn <[EMAIL PROTECTED]> wrote: >> OK, I just listened to the rather lengthy >> HAPOL-02-ObjectsForMaintainableCode.mp3, and have a question. >> >> When using OO, are you multiplying the number of calls do the database? >> Using old school technique, I would do the following using SQL Server >> syntax: >> >> Update Book SET Title='OO baby', NumberofPages=3 WHERE BookID=7 >> (I'm trying to make this example as absolutely as simple as possible). >> >> >> Using OO, would I do something akin to this? >> Book.putTitle(7,'OO baby') >> Book.putNumberofPages(7,3) >> Would that not make two round trips to the database? > >Depends on how you do your objects. More than likely no, you'd set >the title and number of pages as values of properties in an object, >then when you actually persist the data to your database, you're still >only making one call (pseudo-esque code here): >UPDATE book >SET title = <cfqueryparam value="#book.getTitle()#" >cfsqltype="cf_sql_varchar" />, >numberofpages = <cfqueryparam value="#book.getNumberOfPages()#" >cfsqltype="cf_sql_integer" /> >WHERE bookid = <cfqueryparam value="#book.getBookId()#" >cfsqltype="cf_sql_integer" /> > >In other words, when you set values in your object you aren't >necessarily calling your database. You could, but you probably don't >want to. :-) > >Matt >-- >Matt Woodward >[EMAIL PROTECTED] >http://www.mattwoodward.com ---------------------------------------------------------- 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). An archive of the CFCDev list is available at www.mail-archive.com/[email protected]
