| Index
» Projects
» phpMyEdit
» Forum
» Inserting only one record |
 |
plemieux
Joined: 11 May 2005
Posts: 20
Posted: 2005-05-12 18:45
Back to top
Reply with quote
|
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:
| Code: |
| $opts['options'] = 'ACD'; |
to
| Code: |
| $opts['options'] = 'CD'; |
Can someone provide me sample code on how to do that?
|
ajh
Joined: 17 Dec 2003
Posts: 236
Posted: 2005-05-12 19:37
Back to top
Reply with quote
|
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
Joined: 11 May 2005
Posts: 20
Posted: 2005-05-12 19:59
Back to top
Reply with quote
|
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?
|
|
Post new topic
Reply to topic
|
|
|
|