Hi,
I have 7 related tables that contain infpormation about a text entry. Tthe tezt
entry itseld is stores in a table with foreign kleys pointinbg to the related
records in the other tables:
texts - contains the text
these tables contain metadata about the text:
CMSKeys
status
languages
authors
KEYWORDS
copyrights
accessdates
I want to insert metadata in a table, store the last_insert_id in a variable,
store next data in a table etc and then store all last_insert_id's along with
the text in the text table.
Can I insert data in all these tables like this:
<cfquery name="qInsert" datasource="irama">
INSERT INTO CMSKeys(type) VALUES('#arguments.data.type#');
CMSKEY_ID=LAST_INSERT_ID();
INSERT INTO status(code) VALUES('#arguments.data.statuscode#');
STATUS_ID=LAST_INSERT_ID();
INSERT INTO languages(language) VALUES('#arguments.data.language#');
LANGUAGE_ID=LAST_INSERT_ID();
INSERT INTO authors(
firstname,
lastname,
title,
gender,
pseudonym,
notes)
VALUES(
'#arguments.data.author.firstname#',
'#arguments.data.author.lastname#',
'#arguments.data.author.title#',
'#arguments.data.author.gender#',
'#arguments.data.author.pseudonym#',
'#arguments.data.author.notes#');
AUTHOR_ID=LAST_INSERT_ID();
INSERT INTO KEYWORDS(keys) VALUES('#arguments.data.keywords#');
KEYWORDS_ID=LAST_INSERT_ID();
INSERT INTO copyrights(description)
VALUES('#arguments.data.copyrights#');
COPYRIGHTS_ID=LAST_INSERT_ID();
INSERT INTO accessdates(datefrom,dateto)
VALUES('#arguments.data.datefrom#','#arguments.data.dateto#');
ACCESSDATES_ID=LAST_INSERT_ID();
INSERT INTO texts(
data,
description,
FK_keywords,
FK_language,
FK_copyright,
FK_status,
FK_accessdate,
FK_author,
FK_id)
VALUES(
'#arguments.data.text#',
'#arguments.data.description#',
KEYWORDS_ID,
LANGUAGE_ID,
COPYRIGHTS_ID,
STATUS_ID,
ACCESSDATES_ID,
AUTHOR_ID,
CMSKEY_ID);
</cfquery>
Or do I have to use a <cfquery> for each table insert and a <cfquery> to
retrieve the last_insert_id (15 queries if I count ok)?
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~|
Adobe® ColdFusion® 8 software 8 is the most important and dramatic release to
date
Get the Free Trial
http://ad.doubleclick.net/clk;160198600;22374440;w
Archive:
http://www.houseoffusion.com/groups/CF-Newbie/message.cfm/messageid:3481
Subscription: http://www.houseoffusion.com/groups/CF-Newbie/subscribe.cfm
Unsubscribe:
http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=11502.10531.15