Platon Technologies
neprihlásený Prihlásiť Registrácia
SlovakEnglish
open source software development oslavujeme 10 rokov vývoja otvoreného softvéru! Utorok, 24. november 2026
O nás
Magazín
Otvorený softvér
CVS
Služby
Index  »  Projekty  »  phpMyEdit  »  Fórum  »  trigger question

phpMyEdit Configuration     trigger question
Odoslať novú tému   Odpovedať na tému    
 
isegrim     Založený: 11.04.2003   Príspevky: 2  
Príspevok 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)
Príspevok 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  
Príspevok 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)
Príspevok 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  
Príspevok 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    

Copyright © 2002-2006 Platon Group
Stránka používa redakčný systém Metafox
Na začiatok · Odkazový formulár · Prihláška
Upozorniť na chybu na PLATON.SK webstránke · Podmienky použitia · Ochrana osobných údajov