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().getRecordCount()); // 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/
-- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --

Reply via email to