The generated method for a hasOne Related table you will be
getTABLEALIAS() not getTABLEALIASRecord(), if you cfdump your pet object
you will see that it has a getPET_BREED() NOT getPET_BREEDRecord(). 

 

If you meant for it be a hasMany relationship (and you change the xml)
then you would get a getPET_BREEDIterator().

 

 

-----Original Message-----

From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]
On Behalf Of Andy Jarrett

Sent: Monday, March 26, 2007 1:20 PM

To: [email protected]

Subject: Re: [Reactor for CF] Iterator

 

Hi Kevin, Opps yeah that was a typo.

 

Ok ok back to the iterator and record I cannot get this one working. I

can see what is going to happen but I cannot get it to work.

 

Concentrating on the pets shouldn't I be able do:

<cfset reactor = CreateObject("Component",

"reactor.reactorFactory").init(expandPath("/config/reactor.xml")) />

<cfset pet = reactor.createRecord("pets") />

<cfset pet.setpetid(1) />

<cfset pet.load() />

<cfdump var="#pet.getPet_breedRecord()#">

 

At the moment when I try this I can't call the record.

 

Here's the pets xml again

 

<objects name="pets" alias="pets">

      <hasOne name="pet_breed">

            <relate from="pet_breed_id" to="pet_breed_id" />

      </hasOne>                                 

</objects>

 

At the moment when I try the above I get

 

The method 'getPet_breedRecord' could not be found in component

/Users/andyjarrett/Sites/www1/petrescue/model/data/Record/petsRecordmysq
l.cfc.

Check to ensure that the method is defined, and that it is spelled
correctly.

 

My table looks like this

pets

---------------------------------------------------

pet_id                varchar(35)    PK

pet_name         varchar(255)

pet_breed_id   int                     FK to pet_breed.pet_breed_id

 

pet_breed

---------------------------------------------------

pet_breed_id    int                    PK

animal                varchar(255)

breed                  varchar(255)

 

Any help appreciated.

 

Andy

 

 

 

On 26/03/07, Kevin Roche <[EMAIL PROTECTED]> wrote:

> 

> 

> Andy,

> 

> Shouldn't it be:

> 

> <objects name="pet_breed" alias="pet_breed">

>         <hasMany name="pets">

>                 <relate from="pet_breed_id" to="pet_breed_id" />

>         </hasMany>

> </objects>

> 

> so each breed has many pets?

> 

> Kevin

> 

> 

> 

> 

> -----Original Message-----

> From: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED]

> Behalf Of Dave Shuck

> Sent: 26 March 2007 00:41

> To: [email protected]

> Subject: Re: [Reactor for CF] Iterator

> 

> Andy and iterator is only in play when you have a hasMany
relationship.  You

> can get a handle on your pet_breed with:

> 

> 

> <cfset pet = reactor.createRecord("pets").load(petid=1) />

> 

> Then see breed like this:

> <cfdump var="#pet.getpet_breed()#">

> 

> ~Dave

> 

> 

> On 3/25/07, Andy Jarrett <[EMAIL PROTECTED] > wrote:

> > Hi there,

> >

> > I cannot seem to get the "iterator" functions to work but cannot see

> > what I'm doing wrong either. Below is my Reactor File

> >

> > <objects name="pets" alias="pets">

> >         <hasOne name="pet_breed">

> >                 <relate from="pet_breed_id" to=pet_breed_id" />

> >         </hasOne>

> > </objects>

> >

> > <objects name="pet_breed" alias="pet_breed">

> >         <hasOne name="pets">

> >                 <relate from="pet_breed_id" to="pet_breed_id" />

> >         </hasOne>

> > </objects>

> >

> > The code

> > <cfset reactor = CreateObject("Component",

> >

> "reactor.reactorFactory").init(expandPath("/config/reactor.xml"))

> />

> > <cfset pet = reactor.createRecord("pets") />

> > <cfset pet.setpetid(1) />

> > <cfset pet.load() />

> > <cfdump var="#pet#">

> >

> > I've set up the foreign keys from the Pets table on the pet_breed_id

> > column as well. Doesn't matter what I do there is no Iterator

> > available on pet_breed_id.

> >

> > Any ideas on where I am going wrong?

> >

> > Cheers, Andy

> >

> >

> > -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
-- --

> -- --

> > Reactor for ColdFusion Mailing List

> > [email protected]

> > Archives at:

> http://www.mail-archive.com/reactor%40doughughes.net/

> > -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
-- --

> -- --

> >

> >

> 

> 

> 

> --

> ~Dave Shuck

> [EMAIL PROTECTED]

> www.daveshuck.com

> 

> Where's your Spot?

> www.instantspot.com

> -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
-- --

> -- --

> 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/

> -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
-- --

> -- --

 

 

-- 

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/
-- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --

Reply via email to