I believe you can shorten that a bit

newIteratorItem = user.getRolesIterator().add()
newIteratorItem.load(RoleId=??)
user.save()

> -----Original Message-----
> From: [EMAIL PROTECTED] 
> [mailto:[EMAIL PROTECTED] On Behalf Of jonah.blossom
> Sent: 11 April 2007 19:56
> To: [email protected]
> Subject: Re: [Reactor for CF] Reactor question Relationships 
> via Linking Tables
> 
> Matt,
> 
> Here's how I do it:
> 
> <cfscript>
>     user.getRolesIterator().add(); // Adds a new empty item 
> to the end 
> of the array in the iterator.
>     newIteratorItem = 
> user.getRolesIterator().getAt(user.getRolesIterator().getRecor
> dCount()); 
> // Gets that newly added item from the iterator
>     newIteratorItem.setID(roleID); // Sets the ID of the new role you 
> you want to associate. (If you're creating a new role instead, simply 
> set the name, etc. and then don't do load.)
>     newIteratorItem.load(); // Loads the role information from the DB.
>     user.save(); // Persists the user and it's newly added role.
> </cfscript>
> 
> Matt Graf wrote:
> >
> > I am looking at the livedocs and I am unclear on how to use reactor 
> > when I have relationships via linking table. I know how to get the 
> > data out but how do I insert the data into the linking table?
> >
> >  Here is my reactor script
> >
> > <object name="user">
> >    <hasMany name="roles">
> >         <link name="userroles" />
> >    </hasMany>
> > </object>
> >
> > <object name="roles">
> >   <hasMany name="user">
> >        <link name="userroles" />
> >   </hasMany>
> > </object>
> >
> > <object name=" userroles ">
> >    <hasOne name="user">
> >         <relate from="userId" to="userId" />
> >    </hasOne>
> >    <hasOne name="roles">
> >         <relate from="roleId" to="roleId" />
> >    </hasOne>
> > </object>
> >
> >
> > -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 
> -- -- -- 
> > -- -- -- --
> > 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/
> -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 
> -- -- -- -- -- -- --
> 
> 
> 
> 
> 



-- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
Reactor for ColdFusion Mailing List
[email protected]
Archives at: http://www.mail-archive.com/reactor%40doughughes.net/
-- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --

Reply via email to