Hi Andy,
What you're seeing is the expected behaviour of Reactor. Reactor
creates one object class per table. Defining the relationships between
them (hasOne/hasMany) tells Reactor to create methods to access the
related tables.
So in the example of a customer that hasmany orders, If you create an
instance of the customer record, it should contain a method
getOrderIterator which will allow you to access all orders made by that
customer.
If you need to create an object that contains columns from both tables,
then create a view in your database and define it in your reactor.xml.
However this record would be read only, and I'm not sure if this is a
very robust way of handling the situation.
I've not used reactor for an ecommerce/basket type app yet, but as I see
it, it should work something like...
Customer hasmany Order
hasmany Address
Order hasmany Item
hasone Address
hasone Customer
In your xml below, the order object hasmany customers, which doesn't
seem quite right?
Cheers, Chris
-----Original Message-----
From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On
Behalf Of Andy Jarrett
Sent: 23 May 2006 01:36
To: [email protected]
Subject: [Reactor For CF] linked tables
Hi there,
Total Reactor newbie, and I'm having troubles. Problem is don't know
if I'm expecting something of Reactor that it cannot do, or im just
missing something(more than likely)
Puesdo Code:
I have two table which are link by a column called idContact.
Order
-orderid
-orderItem
-idContact
Customer Address
-idContact
-Customer_name
-Customer_address
In the reactor XML i have set these up as a linked table
<object name="order">
<hasMany name="customer">
<link name="customerOrder" />
</hasMany>
</object>
<object name="customer">
<hasMany name="order">
<link name="customerOrder" />
</hasMany>
</object>
<object name="customerOrder">
<hasOne name="customer">
<relate from="idContact" to="idContact" />
</hasOne>
<hasOne name="order">
<relate from="idContact" to="idContact" />
</hasOne>
</object>
I thought that when I used createRecord() it would affectivley treat
this as a single table.
Instead when I use the following and see whats being generated via
_getTo() I only get the information from the "order" table.
<cfset newOrder = variables.reactor.createRecord('order')>
Is this right? Is there a way that I can treat two tables as one??
Well its 1:30am (which probaly isnt helping my brain) so im gonna
switch off from here, go to bed and catch up on House.
Cheers
Andy J
www.andyjarrett.co.uk
-- 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/