[thelist] MySQL Inserts

Andrew Maynes andrew at humanbehaviour.co.uk
Wed Jan 29 03:29:02 CST 2003


Thank you Rudy

>Subject: Re: [thelist] MySQL Inserts

>
>andrew, it's not clear from your post where the $ItemID value comes from

good question... The $ItemID is coming from the table Items and is the PRIMARY
KEY and auto_increment(each record will have a number of related colours to it)
so the PRIMARY in Items is will be related to the same ItemID in ItemColors.

>does the Items table have an auto_increment column?  which column is it?

$ItemID is the auto_increment

>typically, you allow mysql to assign an auto_increment value when it inserts
>a row into a table that has an auto_increment primary key, and then you
>retrieve this value using mysql_insert_id(), and then you use this value
>when inserting rows that contain a foreign key to the row you just inserted
>
>does that make sense?

I think so.... arh I just had a thought, if I am creating an item to insert into
both Items and ItemClor because the auto_increment has not been created and
assigned and inserted into ItemID it can't be simultaneously inserted into
another table because the record doesn't exist?  Is that right?  Or can the same
record be simultaneoult be created in two different tables|?
>
>alternatively, if you are assigning primary key values yourself, then the
>code you posted is probably okay, two inserts using the same value of
>$ItemID

This is what I think I should be doing, using a different column to relate the
two records in two fields, is this realtional database stuff suppposed to be
this easy? :)

Andrew
>
>
>rudy
>
>--
>* * Please support the community that supports you.  * *
>http://evolt.org/help_support_evolt/
>
>For unsubscribe and other options, including the Tip Harvester
>and archives of thelist go to: http://lists.evolt.org
>Workers of the Web, evolt !
>
>---
>Incoming mail is certified Virus Free.
>Checked by AVG anti-virus system (http://www.grisoft.com).
>Version: 6.0.445 / Virus Database: 250 - Release Date: 21/01/2003
>




More information about the thelist mailing list