tonyk
Posts: 163
|
Posted: 08/12/2006, 5:51 AM |
|
I have an application where I have to keep an audit trail of all records entered.
It would be really helpful if the datasource properties had more granularity.
i.e.
DataSource-> function (insert / update / delete)
DataSource->FieldList
That way I could write a function taking values from data source properties and adding to them readily to produce a new function to insert the permanent copy of the record (either new or edited) as part of the audit trail.
Currently I am writing a complete insert statement which is proving to be a bit of a pain on a large form!! Maybe I am missing something that already exists!
Tony
|
 |
 |
wkempees
Posts: 1679
|
Posted: 08/12/2006, 7:10 AM |
|
Is it the record before and after state that you want to copy into a sort of backup table
OR
do you merely want to store the full SQL Insert Update Delete statement into a log table?
For clearity, what kind of INSERT are you writing right now.
(you are CCS2, correct)
W
_________________
Origin: NL, T:GMT+1 (Forumtime +9)
CCS3/4.01.006 PhP, MySQL .Net/InMotion(Vista/XP, XAMPP)
if you liked this info PAYPAL me: http://donate.consultair.eu
|
 |
 |
wkempees
Posts: 1679
|
Posted: 08/12/2006, 7:18 AM |
|
AfterExecute(Insert/Update/Delete)
You have the ability to do:
$statementissued = $Component->ds->SQL;
(replace Component with your componentsname if in CCS2)
then
INSERT into LOGFILE (statement) VALUES( $statementissued)
(logifel : id autonum, statement largeblob) add needed extras like time data etc.
will result in a large logfile with all full SQL statemement as fired since.
W
_________________
Origin: NL, T:GMT+1 (Forumtime +9)
CCS3/4.01.006 PhP, MySQL .Net/InMotion(Vista/XP, XAMPP)
if you liked this info PAYPAL me: http://donate.consultair.eu
|
 |
 |
tonyk
Posts: 163
|
Posted: 08/12/2006, 8:31 AM |
|
Hi wkempees
Thank you for your swift response Do you ever rest!
The backup register contains all entries made in the main register.
If a record in the original register is changed the altered entry is updated in the main register and inserted as a new record into the backup register.
I use a random key generated when a new record is inserted into the main register. This is to overcome any problems obtaining the auto_increment record_id key when a record is inserted into the main register.
Historical values are recovered by selecting on the random key and then the auto_increment key of the backup register.
What I want to do is alter the datasource to INSERT the record into the backup register when updating the main register or inserting a new record into the main register.
I hope this makes sense.
Tony
using CCS 3
p.s.
I suppose I could simple do a string substitution on the $form->DataSource->SQL to generate a new sql statement for use in a temporary connection?
|
 |
 |
wkempees
Posts: 1679
|
Posted: 08/13/2006, 11:55 AM |
|
T,
I think you answered your own post in the "p.s."
All in all it should be possible to do it, after carefully studying how to change the issued UPDATE into a INSERT on another table.
INSERT's you could (simply) string replace the known tablename with the backup tablename, UPDATE has a slgihtly different structure to an INSERT so would need more then just a string replace.
Both case could be based on the theory I wrote earlier.
Interesting stuff, though, but no direct need to expand CCS, do you agree?
Walter
_________________
Origin: NL, T:GMT+1 (Forumtime +9)
CCS3/4.01.006 PhP, MySQL .Net/InMotion(Vista/XP, XAMPP)
if you liked this info PAYPAL me: http://donate.consultair.eu
|
 |
 |
tonyk
Posts: 163
|
Posted: 08/14/2006, 6:20 AM |
|
Agreed,
otherwise we would have nothing to do !!
Tony
|
 |
 |
|