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

phpMyEdit General     Inserting only one record
Odoslať novú tému   Odpovedať na tému    
 
plemieux     Založený: 11.05.2005   Príspevky: 20  
Príspevok Zaslal: 2005-05-12 18:45
Návrat hore  Odpovedať s citátom     

I wish to prevent the user from inserting more than one record for a certain table.

I suppose I need a trigger to check if there is a record and change options accordingly from:

Kód:
$opts['options'] = 'ACD';

to
Kód:
$opts['options'] = 'CD';


Can someone provide me sample code on how to do that?

 
ajh     Založený: 17.12.2003   Príspevky: 236  
Príspevok Zaslal: 2005-05-12 19:37
Návrat hore  Odpovedať s citátom     

The other way of doing it is to create a column in the database table with a unique key. Make that a hidden field in PME with a default value of whatever you want. The first time you enter a record it will be fine, but after that any new records will have the same key as the existing one and you will get an error...I have to say that it won't be pretty, but it will work.

Triggers would be a much better way of doing it, basically you would need to do a SELECT COUNT(*) on the table and not allow an insert if it is greater than 1.

 
plemieux     Založený: 11.05.2005   Príspevky: 20  
Príspevok Zaslal: 2005-05-12 19:59
Návrat hore  Odpovedať s citátom     

I am new to PME and trigger are really not clear to me.

Can you provide me a complete example of how it can be achieved?

 
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