| Index
» Projekty
» phpMyEdit
» Fórum
» Inserting only one record |
 |
plemieux
Založený: 11.05.2005
Príspevky: 20
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
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
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
|
|
|
|