Yes, all three tables have a primary key set. I will start reading on the field tag now, is my code wrong?

On 7/7/06, Matthew Darby < [EMAIL PROTECTED]> wrote:
Dan,

Does your database tables have a primary key set?  Also, you might want to read up on Doug's documentation on the field tag when defining your objects for reactor.


On 7/7/06, Dan Vega <[EMAIL PROTECTED]> wrote:
PLEASE ANYONE!!! :)

I'm sorry if i bothered anyone with the validation question, I just searched the archives and found my answer. I do have a problem though.

I have users,groups and a users_groups table which ties the 2 together. Here is what my config file looks like


        <object name="users">
            <hasMany name="groups">
                <link name="users_groups"/>
            </hasMany>
        </object>
           
        <object name="groups">
            <hasMany name="users">
                <link name="users_groups"/>
            </hasMany>
        </object>
       
        <object name="users_groups">
            <hasOne name="users">
                <relate from="userId" to="userId"/>
            </hasOne>
            <hasOne name="groups">
                <relate from="groupId" to="groupId"/>
            </hasOne>
        </object>


With this configuration in place, if I try and add a user it overwrites the previous record. If I take this out It allows me to keep adding users. Why would these relationships
overwrite in the database? Below is the code where the user is added.


<cfif structKeyExists(form,"submit")>
   
    <cfif form.userId NEQ "0">
        <!--- this lets us know we are updating an existing record, if 0 add new record --->
        <cfset application.UserRecord.setUserId(form.UserId)>
    </cfif>
   
    <cfset application.UserRecord.setUsername(form.username)>
    <cfset application.UserRecord.setPassword (form.password)>
    <cfset application.UserRecord.setEmailAddress(form.emailaddress)>
    <cfset application.UserRecord.setFname(form.fname)>
    <cfset application.UserRecord.setLname(form.lname )>
   
    <!--- validate the user --->
    <cfset application.UserRecord.validate() />
    <cfset errorCollection = application.UserRecord._getErrorCollection() />
   
   
    <cfif NOT ErrorCollection.hasErrors()>
        <!--- save the user and redirect to their view --->
        <cfset application.UserRecord.save()>
        <cflocation URL="" addtoken="false"/>
    </cfif>
   
</cfif>

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



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

Reply via email to