Is locking records possible?

wazz999

New member
I've just started using Dadabik, and it is pretty much what I needed to get things done.
However, I am in the process of building an "exceptions" list, that I need to automatically lock after 24 hours / every night at midnight.
eg : multiple users inputs required data - at midnight, the server/dadabik locks that record so no further edits can be made.

Is this function possible, if so, how?
 

DebbieS

DaDaBIK Guru
It could work by adding another field to the database which would act as an additional switch indicating if the record can be edited or not (eg: 0 = edit, 1 = no edit ... or whatever you want).

Then write an sql function to update all records in the database to make that field 1 in every record of the database at midnight. The SQL would need to be fired via cron job on the server set to midnight daily.

Then you would need to modify the DaDaBIK code to allow editing on records which do NOT have a value of 1 in that field. This way any record with no value (null) would be editable and any record with a value of 1 would not be. Off hand, I don't know how many places in the code you may need to modify this because I don't know how you have your authentication set up for allowing editing.
 

wazz999

New member
Thanks DebbieS

Im quite a noob when it comes to php/cron/html, so I would probably mess up my installation trying to figure out your solution.
What Ive done instead is shedule a cron job to truncate the mysql database at midnight - which means there is no way to edit records, and Im in the prosess of trying to figure out a way to automatically export all daily records into a csv "backup" file - for when previous records need reviewing.
Any chance of implementing an "auto backup" feature in the next release... ;)

Thanks for the help.
 

DebbieS

DaDaBIK Guru
If your cron is truncating the table every night, you could just have the cron copy the records from the table and paste (insert) them into another table before truncating. Then you could install this table in DaDaBIK as read only (by not allowing edit, delete). Then you would still have all records available in your install and users could export data to csv as they need (or search, etc).
 

wazz999

New member
Thats exactly what I was thinking of doing, just need to figure out the syntax for the cron job.

Thanks again.
 

DebbieS

DaDaBIK Guru
Your cron job can simply call a php file located on the server where the SQL statements are stored and executed. Fairly simple really.
 
Top