One of the benefits of doing Object Oriented is in case your database changes (example: from SQL Server to MySQL).
So from my limited understanding, You would have a procedure to issue the update stmt. Something like Create procedure Book.PutTitle( BOOKID AS INTEGER, Title as VARCHAR(8000) ) AS (SQL Server): Update Book set yada yada yada (MySQL): Update 'Book' set yada yada yada So you wouldn't be issuing an update stmt from ColdFusion at all. ColdFusion would be something like: <cfset ReturnCode = Book.PutTitle(7,'OO baby')> -----Original Message----- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Matt Woodward Sent: Friday, December 02, 2005 6:18 PM 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] ---------------------------------------------------------- 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]
