By using cfinvoke to call a component method, you are never instantiating
the component. If you only ever do this, I think you are better off having a
folder of UDFs.

However, if you add a method called init to you cfc that looks like this:

<cffunction name="init" returntype="any">
   <cfargument name="dsn">
   <cfset variables.dsn = arguments.dsn>
   <cfreturn this> <!--- returns instance of the component --->
</cffunction>

You can then get an instance of your object that holds your dsn info using
cfinvoke like so:

<cfinvoke component="mycomponent" method="init" dsn="#application.dsn#"
returnVariable="myComponentInstance">

Then, when you want to call the methods you want you simply do this (instead
of cfinvoke):

<cfset meal = myComponentInstance.getMeal( )>

Hope that makes sense,

Dominic


On 16/10/2007, Morten Kruse <[EMAIL PROTECTED]> wrote:
>
> How do you handle datasources inside CFC's.
> until now I have just been using the variable application.dsn.
>
> But I have been told that I should include the database name in the
> parameter call to the cfc.
>
> But I don't want to call the cfc with the database name every single time
> the cfc is called like:
>        <CFINVOKE COMPONENT="cfc.Meals" METHOD="getMeal"
> dns="#application.dns#" />
>
> Is it possible to invoke the whole component with the database information
> and then call that instance without the dns??
>
>
> 

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~|
Get involved in the latest ColdFusion discussions, product
development sharing, and articles on the Adobe Labs wiki.
http://labs/adobe.com/wiki/index.php/ColdFusion_8

Archive: 
http://www.houseoffusion.com/groups/CF-Talk/message.cfm/messageid:291181
Subscription: http://www.houseoffusion.com/groups/CF-Talk/subscribe.cfm
Unsubscribe: 
http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=11502.10531.4

Reply via email to