Dan,
You should be able to shorten your code here this way:
<cfset customer =
application.cs.getBean("CustomerRecord").load(customerId=url.id)>
load() should return the record... unless this has changed
in the API. It hasn't *that I know of*. The way you have it
written now you end up with 2 customer records...
CustomerRecord and Customer. CustomerRecord is empty and
Customer has data... the former is an unneeded object.
As far as getting the ID while you're looping...
<cfloop query="invoices">
<cfset ciID = invoices.customerInvoiceId>
</cfloop>
Also, this bit here:
<cfset invoices =
customer.getInvoiceIterator()._getQuery()>
Should probably be:
<cfset customerInvoices =
customer.getCustomerInvoiceIterator()._getQuery()>
IIRC, the results from that call should be a join between
the Invoice table and the Customer table based on the
customerId in the current instance of Customer... you
should actually have 2 iterators as members in your
Customer object, one for Invoices and one for
CustomerInvoices, because of the hasMany linkages between
the various object tags.
I may be wrong, and I'm working entirely from memory
here... but if I remember correctly that's how it SHOULD
work.
Someone please correct me if I'm wrong?
Laterz,
J
On Mon, 10 Jul 2006 12:49:44 -0400
"Dan Vega" <[EMAIL PROTECTED]> wrote:
> Let's say for example I have 3 tables.
> Product,Invoice,ProductInvoice and my
> reactor.xml looks like this.
>
> <object name="Customer">
> <hasMany name="Invoice">
> <link name="CustomerInvoice"/>
> </hasMany>
> </object>
>
> <object name="Invoice">
> <hasMany name="Customer">
> <link name="CustomerInvoice"/>
> </hasMany>
> </object>
>
> <object name="CustomerInvoice">
> <hasOne name="customer">
> <relate from="customerId"
> to="customerId"/>
> </hasOne>
> <hasOne name="Invoice">
> <relate from="invoiceId" to="invoiceId"/>
> </hasOne>
> </object>
>
>
> If I am in my admin area and viewiing a customers
> invoices i can loop them
> using the following query
>
> <cfset customerRecord =
> application.cs.getBean("CustomerRecord")>
> <cfset customer = customerRecord.load(customerId=url.id)>
>
> <cfset invoices =
> customer.getInvoiceIterator()._getQuery()>
>
> So Up to there works fine, the question I have is, when I
> am looping the
> invoices query how do i find the related id's? In the
> CustomerInvoice table
> there is customerInvoiceID,customerId,invoiceId, I
> specifically need the
> customerInvoiceID each time I pass through the loop.
>
>
>
> --
> Dan Vega
> [EMAIL PROTECTED]
>
>
> -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
> -- -- -- -- -- -- -- --
> Reactor for ColdFusion Mailing List
> [email protected]
> Archives at:
> http://www.mail-archive.com/reactor%40doughughes.net/
> -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
> -- -- -- -- -- -- -- --
-- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
Reactor for ColdFusion Mailing List
[email protected]
Archives at: http://www.mail-archive.com/reactor%40doughughes.net/
-- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --