Thats what I thought was happening as well but i am logging form.userId before and after. That setUserId(form.userId) method is never being called so it should just auto increment.

On 7/7/06, Matthew Darby <[EMAIL PROTECTED]> wrote:
You are right about that, I wasn't sure at first if you needed it.  One thing I am wondering is though whenever you are performing the add process for the user are you sure that the userid is 0?  Or is the form carrying over the previous userid?  I know it sounds silly, but for right now with what code you have presented its the first question that comes to mind.

On 7/7/06, Dan Vega < [EMAIL PROTECTED]> wrote:
So the field tag makes alot of sense and should be used but i dont think thats my problem here. I am usin MySQL 5x as well.

On 7/7/06, Dan Vega < [EMAIL PROTECTED]> wrote:
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/
-- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --



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



--
Matt D.
http://matthewdarby.com


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