Platon Technologies
not logged in Login Registration
EnglishSlovak
open source software development celebrating 10 years of open source development! Wednesday, April 29, 2026
About Us
Magazine
Open Source
CVS
Services
Index  »  Projects  »  phpMyEdit  »  Forum  »  Inserting only one record

phpMyEdit General     Inserting only one record
Post new topic   Reply to topic    
 
plemieux     Joined: 11 May 2005   Posts: 20  
Post 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  
Post 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  
Post 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    

Copyright © 2002-2006 Platon Group
Site powered by Metafox CMS
Go to Top · Feedback form · Application form
Report bug on PLATON.SK website · Terms of use · Privacy policy