Database Help
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me
Go Back   Codewalkers ForumsOther TechnologiesDatabase Help

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Codewalkers Forums Sponsor:
Stay one step ahead of the competition. Evaluate and give feedback on some of the hottest web development tools on the market today. Make your opinion heard! Click Here
  #1  
Old January 7th, 2003, 02:30 AM
superalloy superalloy is offline
Codewalkers Newbie (0 - 499 posts)
 
Join Date: Apr 2007
Location: Washington DC
Posts: 58 superalloy User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 2
Multiple Table INSERTs with FKs

I want to populate several MySQL tables from a php script, two info tables and a link table that allows for a many to one relationship. I have auto_incrementing primary keys on both information tables.

Is there a better way to quickly get the link table information without having to (my current method):

1. populate both tables and include a temporary field value

2. query both tables for temporary field value

3. populate link table

4. update temporary field values.

Thanks


Reply With Quote
  #2  
Old January 8th, 2003, 12:51 AM
Anonymous Anonymous is offline
Registered User
Codewalkers God 35th Plane (22000 - 22499 posts)
 
Join Date: Apr 2007
Posts: 22,309 Anonymous User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 24
RE: Multiple Table INSERTs with FKs

What's the point of the temporary field value?

Reply With Quote
  #3  
Old January 8th, 2003, 01:47 AM
superalloy superalloy is offline
Codewalkers Newbie (0 - 499 posts)
 
Join Date: Apr 2007
Location: Washington DC
Posts: 58 superalloy User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 2
RE: Multiple Table INSERTs with FKs

if i am setting up a many to many relationship, then i need some way to identify the row until i can query it and get the primary key.

I have been looking around and I think a better method is to use the mysql_insert_id() function and retrive the id after i persist the record, then use them to populate a link table.

Reply With Quote
  #4  
Old January 8th, 2003, 02:13 AM
Anonymous Anonymous is offline
Registered User
Codewalkers God 35th Plane (22000 - 22499 posts)
 
Join Date: Apr 2007
Posts: 22,309 Anonymous User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 24
RE: Multiple Table INSERTs with FKs

Yes, using mysql_insert_id would definately be a better method....


Reply With Quote
Reply

Viewing: Codewalkers ForumsOther TechnologiesDatabase Help > Multiple Table INSERTs with FKs


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 4 hosted by Hostway