Do you have a question? Post it now! No Registration Necessary. Now with pictures!
- Posted on
- Any Ideas about that ...
June 16, 2005, 12:09 pm
rate this thread
I have a table Products and a table Files.
Each product may have from 0 to 10 or more files associated with it. So it
is a 1 to M relationship...
My problem is that I cannont see how I can associate files to the product at
the time of Product insertion to the DB.
And this is because I don't know the ID taht the product is going to take
before it is inserted into the DB.
So any IDEAS ?
Re: Any Ideas about that ...
First insert the product, then get the id for it using last_insert_id()
and then insert rest of the rows, using that id. (C, PHP and other
implementations have direct function for that, with ODBC you need to run
new query to get it).
And the id last_insert_id() returns is safe to use even with many users,
because it is attached to the current connection. So user with another
connection wont get the id you used in another connection.
- » Americanas.com SALDO de TVs Com at 80% de Desconto (29798)
- — Newest thread in » MySQL Database Forum