[allowsmilie] => 1 [showsignature] => 0 [ipaddress] => [iconid] => 0 [visible] => 1 [attach] => 0 [infraction] => 0 [reportthreadid] => 0 [isusenetpost] => 1 [msgid] => [ref] => [htmlstate] => on_nl2br [postusername] => Stressed_Simon [ip] => webforumsuser@m [isdeleted] => 0 [usergroupid] => [membergroupids] => [displaygroupid] => [password] => [passworddate] => [email] => [styleid] => [parentemail] => [homepage] => [icq] => [aim] => [yahoo] => [msn] => [skype] => [showvbcode] => [showbirthday] => [usertitle] => [customtitle] => [joindate] => [daysprune] => [lastvisit] => [lastactivity] => [lastpost] => [lastpostid] => [posts] => [reputation] => [reputationlevelid] => [timezoneoffset] => [pmpopup] => [avatarid] => [avatarrevision] => [profilepicrevision] => [sigpicrevision] => [options] => [akvbghsfs_optionsfield] => [birthday] => [birthday_search] => [maxposts] => [startofweek] => [referrerid] => [languageid] => [emailstamp] => [threadedmode] => [autosubscribe] => [pmtotal] => [pmunread] => [salt] => [ipoints] => [infractions] => [warnings] => [infractiongroupids] => [infractiongroupid] => [adminoptions] => [profilevisits] => [friendcount] => [friendreqcount] => [vmunreadcount] => [vmmoderatedcount] => [socgroupinvitecount] => [socgroupreqcount] => [pcunreadcount] => [pcmoderatedcount] => [gmmoderatedcount] => [assetposthash] => [fbuserid] => [fbjoindate] => [fbname] => [logintype] => [fbaccesstoken] => [newrepcount] => [vbseo_likes_in] => [vbseo_likes_out] => [vbseo_likes_unread] => [temp] => [field1] => [field2] => [field3] => [field4] => [field5] => [subfolders] => [pmfolders] => [buddylist] => [ignorelist] => [signature] => [searchprefs] => [rank] => [icontitle] => [iconpath] => [avatarpath] => [hascustomavatar] => 0 [avatardateline] => [avwidth] => [avheight] => [edit_userid] => [edit_username] => [edit_dateline] => [edit_reason] => [hashistory] => [pagetext_html] => [hasimages] => [signatureparsed] => [sighasimages] => [sigpic] => [sigpicdateline] => [sigpicwidth] => [sigpicheight] => [postcount] => 7 [islastshown] => [isfirstshown] => [attachments] => [allattachments] => ) --> CFTransaction and CFC - Coldfusion - Advanced Techniques

CFTransaction and CFC - Coldfusion - Advanced Techniques

Hi All, I have a 6 existing queries that I would like to move into a CFC. Where do I place the <cftransaction> tag?? Do I have to put it within each function?? Thanks in advance....

  1. #1

    Default CFTransaction and CFC

    Hi All, I have a 6 existing queries that I would like to move into a CFC. Where do I place the <cftransaction> tag?? Do I have to put it within each function??

    Thanks in advance.
    EdmondsM Guest

  2. #2

    Default CFTransaction and CFC

    Hi All, I have a 6 existing queries that I would like to move into a CFC. Where do I place the <cftransaction> tag?? Do I have to put it within each function??

    Thanks in advance.
    EdmondsM Guest

  3. #3

    Default Re: CFTransaction and CFC

    Depends on which queries you want to group as transactions and what your functions do.
    Dan Guest

  4. #4

    Default Re: CFTransaction and CFC

    Place each query in a separate function. Then have a main public function that calls them all. Use cftransaction in this and use logic to call the functions you want.

    Make sense?
    Stressed_Simon Guest

  5. #5

    Default Re: CFTransaction and CFC

    Double post:-

    http://www.macromedia.com/cfusion/webforums/forum/messageview.cfm?catid=7&thread
    id=1075414&CFID=22046812&CFTOKEN=99ed425bf965ffe5-9D308D3D-F572-EFFE-1C199404B56
    14E92&jsessionid=48305bfd934c2b341f38

    Stressed_Simon Guest

  6. #6

    Default Re: CFTransaction and CFC

    OK so in theory looking at Strssed_Simons answer you could have one object/CFC
    with different methods:functions in it running different queries and wrap a
    transaction around all the method/function calls:

    Do you think the below code would be fine to run from a CFM page, if not why
    not?

    cheers
    Martin

    Code:
    <cfset updateObj =
    createObject("component","#request.cfcPathQRY#.QRY_EDIT_update")>
    <cftransaction>
    <cfinvoke component="#updateObj#" method="recalculate">
    <cfinvoke component="#updateObj#" method="updateSingleShot">
    </cftransaction>
    MartinThorpe Guest

  7. #7

    Default Re: CFTransaction and CFC

    Nearly what I meant, I actually meant do the whole lot in a cfc:-



    <!--- this is how you call the method --->
    <cfset createObject("component", "myComponent").controller()>


    <!--- the component --->
    <cfcomponent>
    <cffunction name="controller" access="public" output="false"
    returntype="void">
    <cftransaction>
    <cfinvoke method="recalculate">
    <cfinvoke method="updateSingleShot">
    </cftransaction>
    </cffunction>

    <cffunction name="recalculate" access="private" output="false"
    returntype="void">
    <cfquery datasource="myDSN">
    <!--- query stuff --->
    </cfquery>
    </cffunction>

    <cffunction name="updateSingleShot" access="private" output="false"
    returntype="void">
    <cfquery datasource="myDSN">
    <!--- query stuff --->
    </cfquery>
    </cffunction>
    </cfcomponent>

    Stressed_Simon Guest

  8. #8

    Default Re: CFTransaction and CFC

    Yeah I understand what you mean about creating it in a component, in my case it
    is not what I want to do.

    Just thinking if it would be the same if not in a component, say from a model
    template cfm file calling components, in your instance in the page where you
    are calling the method.

    I see it is the same thing really what do you think would be the advantages of
    dealing with it all in a component as opposed to the method calls outside of
    the component except maybe improved performance?!?!

    MartinThorpe Guest

  9. #9

    Default Re: CFTransaction and CFC

    The advantage is that if these database calls actually belong together and they
    should be in a transaction then you can ecapsulate all you business rules in
    one location. Therefore all you need to worry about in the future is calling a
    function and passing it the relevant parameters, and you business rules are
    protected by design. You don't have to remeber every time that you use this
    functionality that it needs to be in a transaction because you built it to do
    that in the function.

    Code reusability.

    Stressed_Simon Guest

Similar Threads

  1. cftransaction
    By mjwjal in forum Coldfusion Database Access
    Replies: 17
    Last Post: November 6th, 03:45 PM
  2. is this possible - cftransaction
    By jppa in forum Coldfusion - Advanced Techniques
    Replies: 4
    Last Post: March 1st, 08:51 PM
  3. cftransaction question
    By Netopole in forum Macromedia ColdFusion
    Replies: 2
    Last Post: February 22nd, 04:19 PM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •