Yes, that's one way to do it. You can also instantiate an instance of the
newsletter cfc and call the methods directly. So..;
<cfcomponent name="user">
<cfset variables.newsManager = createObject("component", "newsmanager")>
.....
<!--- Check if user has subscribed to any newsletters. If so, insert them
--->
<cfif (arguments.userMailingListID) IS NOT "">
<cfset newsresult =
variables.newsManager.insertNewsSubscription(user_id =arguments.userid,
newcat_id = arguments.usermailinglistid)>
> </cfif>
</cfcomponent>
Whether your want to instantiate or invoke depends on the life cycle of your
user object and whether or not you want to call multiple methods in your
newsletter manager.
On 2/13/06, Aaron Roberson <[EMAIL PROTECTED]> wrote:
>
> Deanna wrote:
> Well, you could have some object aggregation. So, for example, the user
> CFC
> could have an instance of the newsletterManager cfc. So, if a new user is
> created, and they've requested access to certain newsletters, you'd just
> run
> the functions from within the user cfc. Or, if you instantiate a user as
> an
> object, there should be a "getId()" function that can be called once it's
> been instantiated. Then, use that id in a separate call to the newsletter
> cfc.
>
> Deanna and James,
> Because I am new to CFC's and OOP, could you help me understand how to
> implement the advice above?
>
> This is what I am guessing I should do:
>
> Inside the insertUser method of the users component, I should invoke
> the insertSubscriber method of the newsletter manager component and
> pass it the userID. Is that it?
>
> Would it look like the following code?
>
> <!--- Check if user has subscribed to any newsletters. If so, insert them
> --->
> <cfif (arguments.userMailingListID) IS NOT "">
> <cfinvoke
> component="WhiteHorse.components.newsletter"
> method="insertNewsSubscription"
> returnvariable="insertNewsSubscriptionRet">
> <cfinvokeargument name="user_ID"
> value="#arguments.userID"/>
> <cfinvokeargument name="newscat_ID"
> value="#arguments.userMailingListID#"/>
> </cfinvoke>
> </cfif>
>
> Your help is greatly apreciated!
> -Aaron
>
>
> On 2/11/06, James Holmes <[EMAIL PROTECTED]> wrote:
> > The MAX(ID) technique only works 100% if you use a serializable
> > transaction in the cftransaction tag, which can impact performance.
> >
> > On 2/12/06, Mike Soultanian <[EMAIL PROTECTED]> wrote:
> > > If you're sure about that, go with it. However, from a previous
> > > conversation, it didn't seem that was the consensus... but I could
> very
> > > well be wrong...
> > >
> > > Mike
> > >
> > > Aaron Rouse wrote:
> > > > It does a transaction in the database itself, assuming the database
> being
> > > > used supports transactions. This would ensure that you get back the
> ID that
> > > > you just inserted.
> >
> > --
> > CFAJAX docs and other useful articles:
> > http://jr-holmes.coldfusionjournal.com/
> >
> >
>
>
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~|
Message: http://www.houseoffusion.com/lists.cfm/link=i:4:232147
Archives: http://www.houseoffusion.com/cf_lists/threads.cfm/4
Subscription: http://www.houseoffusion.com/lists.cfm/link=s:4
Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=89.70.4
Donations & Support: http://www.houseoffusion.com/tiny.cfm/54