close ad
Databridge V2 with MySQLi support IS Now Available!
open ad
View Menu

Technical Support Forums

Free, outstanding support from WebAssist and your colleagues

rating

Register Issues

Thread began 10/05/2010 2:01 pm by fdotmedia | Last modified 10/06/2010 12:26 pm by Jason Byrnes | 873 views | 8 replies |

fdotmedia

Register Issues

Can I update two tables on one submit or do I need to inner join, left join or full join the tables?

Example:
I want to have a registration form that updates all the details you would hope a form to have... Some of those update able input fields are located in several different tables, User(UID), UserDetails(UDID), UserClass(UCID), Class(CID), ClassDetails(CDID), Franchise(FID) and FranchiseDetails(FDID).

I have the Users mysql table built like so...

CREATE TABLE `UserDetails` (
`UDID` int(10) NOT NULL auto_increment,
`FID` int(10) NOT NULL,
`UFname` varchar(255) NOT NULL,
`ULName` varchar(255) NOT NULL,
`USSN` int(9) NOT NULL,
`UCity` varchar(255) NOT NULL,
`UState` varchar(255) NOT NULL,
`UZipcode` int(5) NOT NULL,
`UPhone1` varchar(255) NOT NULL,
`UPhone2` varchar(255) NOT NULL,
`UReferred` varchar(255) NOT NULL,
`ULevel` int(2) NOT NULL,
PRIMARY KEY (`UDID`)
) ENGINE=InnoDB AUTO_INCREMENT=2 DEFAULT CHARSET=utf8 AUTO_INCREMENT=2 ;



I want to add the appropriate details to this table as well...

CREATE TABLE `User` (
`UID` int(10) NOT NULL auto_increment,
`CID` int(10) NULL,
`FID` int(10) NULL,
`UDID` int(10) NULL,
`UEmail` varchar(255) NOT NULL,
`UPass` varchar(255) NOT NULL,
PRIMARY KEY (`UID`)
) ENGINE=InnoDB AUTO_INCREMENT=2 DEFAULT CHARSET=utf8 AUTO_INCREMENT=2 ;



I still have the other 5 tables with literally the same question...

I want to carry the details in the smallest possible table as possible right? Store as much data in Session as possible right?

So again, do I JOIN all the tables in the registration page, put all the necessary details in Session and pull out the appropriate data based on 'ULevel' then? If so, which JOIN is best? If not, what would you suggest?

Any help would be great!

Thanks,
Ted

Sign in to reply to this post

Jason ByrnesWebAssist

yes, you could insert the user data into multiple tables. you would need to add an insert record behavior for each table, and make sure only the last insert record behavior has a redirect URL set.

Sign in to reply to this post

fdotmedia

Awesome... That's a much better fix than the alternative...

A weird thing happened though... I get the following error...

Cannot add or update a child row: a foreign key constraint fails (`RTN/UserDetails`, CONSTRAINT `UserDetails_ibfk_1` FOREIGN KEY (`UDID`) REFERENCES `UserDetails` (`UDID`) ON DELETE CASCADE ON UPDATE CASCADE)



any ideas? Is that because I have the wrong details pointed inside mySQL?

Sign in to reply to this post

Jason ByrnesWebAssist

do you get this error when adding a row or updating a row.


basically the error is telling you that a foreign key restraint you have specified in the database is causing the operation to fail.

I generally dont add foreign keys to the database and code the application to handle them instead.

Sign in to reply to this post

fdotmedia

It was on WA_Insert... I've since taken them out of the DB and am now trying to handle it on the page...

On that same note - do you use InnoDB or MYISAM for your Storage Engine?

Thanks for your help again Jason!

Sign in to reply to this post

fdotmedia

OK - I got it to work perfectly - I only have one issue...

in my Users Table I have the following:

`UID` int(10) NOT NULL auto_increment,
`CID` int(10) default NULL,
`FID` int(10) default NULL,
`UDID` int(10) default NULL,
`CTID` int(10) default NULL,
`UEmail` varchar(255) default NULL,
`UPass` varchar(255) default NULL,



in my UserDetails table I have the following:

`UDID` int(10) NOT NULL auto_increment,
`FID` int(10) NOT NULL,
`UFName` varchar(255) NOT NULL,
`ULName` varchar(255) NOT NULL,
`USSN` varchar(11) NOT NULL,
`UCity` varchar(255) NOT NULL,
`UState` varchar(255) NOT NULL,
`UZipcode` int(5) NOT NULL,
`UPhone1` varchar(255) NOT NULL,
`UPhone2` varchar(255) default NULL,
`UReferred` varchar(255) NOT NULL,
`ULevel` int(2) NOT NULL default '1',



How do I get the UDID to populate the incremental one in the UserDetails table as well as the row in the Users table?

I have tried the pulling the UDID out of session, the post value from the registration form and any other way I can think of...

Everything I've tried the table has remained empty...

Any ideas?

Sign in to reply to this post

Jason ByrnesWebAssist

you cannot set the value of the primary key column in the details table, you should use a foreign key column instead.

it looks like you have the fid column in the details table for this.

Using DataAssist insert record, the ID is stored in a session variable. On the first page, see the session variables section.

make sure the Insert to the Users table occurs before the insert to the details

in the insert to the details, set the fid column to use the session created by the Users insert

Sign in to reply to this post

fdotmedia

YEAH! genius I tell you...

Thanks Jason!

Sign in to reply to this post

Jason ByrnesWebAssist

you're welcome.

Sign in to reply to this post

Build websites with a little help from your friends

Your friends over here at WebAssist! These Dreamweaver extensions will assist you in building unlimited, custom websites.

Build websites from already-built web applications

These out-of-the-box solutions provide you proven, tested applications that can be up and running now.  Build a store, a gallery, or a web-based email solution.

Want your website pre-built and hosted?

Close Windowclose

Rate your experience or provide feedback on this page

Account or customer service questions?
Please user our contact form.

Need technical support?
Please visit support to ask a question

Content

rating

Layout

rating

Ease of use

rating

security code refresh image

We do not respond to comments submitted from this page directly, but we do read and analyze any feedback and will use it to help make your experience better in the future.

Close Windowclose

We were unable to retrieve the attached file

Close Windowclose

Attach and remove files

add attachmentAdd attachment
Close Windowclose

Enter the URL you would like to link to in your post

Close Windowclose

This is how you use right click RTF editing

Enable right click RTF editing option allows you to add html markup into your tutorial such as images, bulleted lists, files and more...

-- click to close --

Uploading file...