| Index
» Projekty
» phpMyEdit
» Fórum
» trigger question |
 |
isegrim
Založený: 11.04.2003
Príspevky: 2
Zaslal: 2003-06-13 13:09
Návrat hore
Odpovedať s citátom
|
I want to have an 'insert after' trigger, meaning I wanna run a script after adding a new record to the table.
Question: can I get the value of the primary key assigned to that new entry in a variable ? For deleting and updating this seems to be possible with $this->rec, but not for inserting.
Any suggestions ?
|
nepto
Založený: 06.01.2003
Príspevky: 320
Bydlisko: Phoenix, Arizona (USA)
Zaslal: 2003-06-13 21:21
Návrat hore
Odpovedať s citátom
|
You are right this is not possible. You have to perform an addiotional query by yourself in INSERT trigger. Something like this:
| Kód: |
| SELECT LAST_INSERT_ID(); |
Note, that this is strongly MySQL depended and probably won't work on the other RDBMS.
|
Aragorn69
Založený: 06.02.2004
Príspevky: 2
Zaslal: 2004-02-06 16:23
Návrat hore
Odpovedať s citátom
|
I have the same problem. But i wonna write new record into another table with the same id of the table i inserted before.
The id is autoincrement..
Can anyone tell me how is it possible?
I used te cgi persist variable.. but it apparently not function with the autoincrement variables.
The query "SELECT LAST_INSERT_ID();" return a string as:"Resource id#7".. why?
Thank's a lot.
|
nepto
Založený: 06.01.2003
Príspevky: 320
Bydlisko: Phoenix, Arizona (USA)
Zaslal: 2004-02-07 10:41
Návrat hore
Odpovedať s citátom
|
That is only a "result". You have to call mysql_fetch_row() function on the result to get actual data. More information is located in the PHP documentation.
_________________ Ondrej Jombik (Nepto)
Visit my
homepage
, review my recent
CV
or
projects
and give me some
feedback
.
|
Aragorn69
Založený: 06.02.2004
Príspevky: 2
Zaslal: 2004-02-13 12:59
Návrat hore
Odpovedať s citátom
|
I use the "mysql_insert_id()" function.
It works fine!
Hi.
|
|
Odoslať novú tému
Odpovedať na tému
|
|
|
|