Welcome, Guest
Username: Password: Remember me

TOPIC: [SOLVED] Tracking of transactions within the component

[SOLVED] Tracking of transactions within the component 31 Aug 2012 14:44 #3347

  • dares
  • dares's Avatar
  • Offline
  • Junior Member
  • Posts: 37
  • Thank you received: 4
  • Karma: 2
Hi,

I have to create an component which will be able to manipulate two tables from one single form.
Lets say you have two tables, table A and table B
Contents from table A are "live data". You should be able to create new records, modify existing records using the form.
Contents from table B are "log data" and is used to track changes of "live data" from table A. Records in table B should never be modified and/or deleted. Only insert of new entry is possible and is done automaticly from the form which is used for "live data". Also deleting of the item from the table A should be recorded in the table B.
So for example,
Table A contains fields for "first name", "last name" and "Place" which will be created/updated from the form. Fields "creation date", "created by", "modify date" and "modified by" will be automatic created/updated. This is easy and works good.
Table B contains same fields as table A and one additional field "Record ID" which should be filled in with the ID value of the record from table A.

Is this possible to do with Cook without need to change files after download of component?
73,
Miro

Cook saves your time and make your life easier.
The administrator has disabled public write access.

Re: Tracking of transactions within the component 31 Aug 2012 16:55 #3348

  • admin
  • admin's Avatar
  • Offline
  • Administrator
  • Chef
  • Posts: 3711
  • Thank you received: 987
  • Karma: 140
Well, I guess you are creating a kind of versioning.
It is on the roadmap but maybe not before 10 months (more or less)


If I understood, you want is to be able to keep in DB all singles modifications of the item entry (the versions)

A versioning system permit to
- virtually go back in time (time machine like)
- virtually ignore an author, and display others versions of the item (last in time)
- keep and show current values before a content has been approved.
- have fallbacks when item is not found (used for languages for example)
- ...

Well, I never studied what is the best method to realize it, so my advices can be wrong.
I show you the simpliest, but not the best. (really simple use)

TODO :
- Use only one table !
- Create additional fields in your table (fk_parent, creation_date)
- fk_parent is pointing the same table (recursive, but uses only 1 level)
- creation_date : Implement the Wizard to create it.

Then you code something that, instead of updating the item, it creates a clone in DB.
This clone store in fk_parent, the id of the original item (Let's say ALWAYS the first version of it, it is more easy)

Change the listig query to filter and get ONLY the last versions items. You can struggle here. Try to create it ONLY in SQL (no php itteration please !)
Maybe some extensional fiels can be created (ex: current_version, approved, etc...) to help you building a fast query. And depending what you really want.


If you are storing a lot of datas, you need to consider it !
So you may need to clean sometimes your versions, but always keep the original row of the item, updating it with the last version values, when you clean it.

I am almost sure it exist a better system. A kind of 'strategy' to do it correctly and powerfull.

If you find a good method, please propose it here.

Anyway, you really need to code, there are no others solutions for the moment.
Coding is now a piece of cake
The administrator has disabled public write access.

Re: Tracking of transactions within the component 04 Sep 2012 14:24 #3375

  • dares
  • dares's Avatar
  • Offline
  • Junior Member
  • Posts: 37
  • Thank you received: 4
  • Karma: 2
Hi,
You understood me good what I need.
I think I will apply changes in the files after download and still using separate table for logging (versioning) until this is implemented in Cook.
Thank you for your advice and answer. I hope also that the versioning will be supported soon, because it is very useful (for example in Asset Management).

P.S.
It is not possible to add [Solved] to topic name because of max char in topic.
73,
Miro

Cook saves your time and make your life easier.
Last Edit: 04 Sep 2012 14:27 by dares.
The administrator has disabled public write access.
Time to create page: 0.068 seconds

Get Started