473,394 Members | 1,674 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,394 software developers and data experts.

Any Ideas about that ...

Hello ...

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 ?
Thanks Angelos
Jul 23 '05 #1
2 1209
Angelos wrote:
And this is because I don't know the ID taht the product is going to take
before it is inserted into the DB.


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.

C:
http://dev.mysql.com/doc/mysql/en/ge...unique-id.html

PHP:
http://fi2.php.net/manual/fi/functio...-insert-id.php

ODBC:
http://dev.mysql.com/doc/mysql/en/od...insert-id.html
Jul 23 '05 #2
> 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. PHP:
http://fi2.php.net/manual/fi/functio...-insert-id.php


THanks a lot man ....

Thats great news !!!!
Jul 23 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
by: FLEB | last post by:
I like PHP for its excellent inline integration into standard HTML files, but I like Perl for its quick-moving syntax and simpler data-processing. To resolve this deep-seated inner turmoil (oh, the...
3
by: Slash | last post by:
Hello everyone I'm looking for seminar topics (and project ideas too) for my final year in Computer Engineering. I'm considering doing something on C++/Linux, considering that I love it so much...
0
by: Rupa Mantravadi | last post by:
I am looking for some ideas to design my application's opening screen. I currently have menu options as a tree view. I would like to know more ideas or sites where I can find some screen shots of...
3
by: Charulatha Kalluri | last post by:
Hello folks, I'm on the lookout for project ideas for a C++ class. The project should: -Be a "fairly complex" application
10
by: Mark | last post by:
I need some ideas for tables in my MDB. right now I have an "text editor" table, a "Projects" table, and a "contacts" table. Can anyone give me any ideas? Thanks! - Mark
0
by: greg | last post by:
I created deployment project for my web application (to install on the same computer so I dont need to add runtime) Added project output AND content files would not build content...
0
by: marfi95 | last post by:
Basically, I keep the state of some objects serialized in an xml file through the use of a data set. The xml file serialized is persisted onto a shared network drive. However, the file is only...
12
by: Anthony Greene | last post by:
Hello, I know this isn't really a python centric question, but I'm seeking help from my fellow python programmers. I've been learning python for the past year and a half, and I still haven't...
0
by: bcannon | last post by:
At Guido's suggestion, a new mailing list has been created named Python-Ideas (http://mail.python.org/mailman/listinfo/python-ideas). This list is meant as a place for speculative, pie-in-the-sky...
0
by: mistersexy | last post by:
I have been programming in python for some time but I have become short of ideas. A software exhibition is coming up, and I plan to show python's worth 'cos it is quite underrated in this part of...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.