mlapl1
Posts: 66
|
| Posted: 06/03/2008, 9:03 PM |
|
Dear All,
Is there a piece of simple code or a built-in function in CCS4 which will allow me to count the number of times a particular database record is accessed? I presume a special field would have to be created in the database table but I do not have a clear picture of how to increment it using CCS.
Thanks for your help.
Andrew
|
 |
 |
kevind
Posts: 251
|
| Posted: 06/04/2008, 3:50 AM |
|
Quote mlapl1:
Dear All,
Is there a piece of simple code or a built-in function in CCS4 which will allow me to count the number of times a particular database record is accessed? I presume a special field would have to be created in the database table but I do not have a clear picture of how to increment it using CCS.
Thanks for your help.
Andrew
if you are accessing the record from a link, you can place a parameter in the link like 'countAccess' and look for it in the Before Show event of the page the link points to - then, if it is present, use some custom SQL to increment a field in that record.
you can also just put the custom SQL in the before show event of the record / record page but, this might increment the count when the user refreshes the page
so i would do(ASP):
link (parameter set to countAccess=1)
in the BeforeShow Page Event of the page
if CCGetParam("countAccess",empty)=1 then
- execute my custom SQL
- redirect to the same page, removing the countAccess parameter
If you need help with the Custom SQL and redirect - let me know
option 2 - non custom code way
========================
- create a record on the same page that calls uses the same criteria as the main record, but only references the counter field
- in the before show event of the record, set the value of the counter field to itself + 1
- in the before show event of the page set an action to hide the form if the parameter
countAccess is empty
- in the before show event of the form, add an action on the client side to submit the form
- in the return page value, set it to the same page
- in the remove parameters/ property, put the countAccess parameter name
** option 2 relies on the user having javascript enabled for your site in order to submit the form **
Regards
Kevin
_________________
thanks
Kevin
======================
CCS 3.2.x / ASP / MS Access /mySQL / PHP / jQuery / jQuery UI / jQuery Mobile
|
 |
 |
marcwolf
Posts: 361
|
| Posted: 06/09/2008, 4:06 PM |
|
Hi Kevind
That would work.. Except that you would also be counting the acesses for updates and re-displays.
I had a similar issue where my client wanted to log who was accessing what record. And what changes they made.
The changes and inserts were easy, however the 'reads' were not
i.e.
user selects record 5 and before Show Event triggered
(read of 1)
User updates record
(Update of 1)
Record is automatically re-displayed triggering Brefore Show Event
(read of 2)
This in effect is erronous because your should only need to refer to the first read of 1.
The best was I counteract this is to do the read action on the page that calls or links to the record you want to count.
This can be done as a small pass-through page where the counting is done. This page is only displayed for an instance
Or using Ajax or some other call back facility like Remote Scripting to do it.
Either way will work and you will have the correct counts at the end of the day.
Take care
Dave
p.s. - triggers are also excellent devices for comparing before and after pictures on the database for auditing.
_________________
' Coding Coding Coding
Keep Those Keyboards Coding.
Raw Code!!!!!!!
|
 |
 |
mlapl1
Posts: 66
|
| Posted: 06/09/2008, 5:04 PM |
|
Thank you for your advice everyone. i am not a php/sql coder but this is simple enough for me to experiment with a little bit and see what happens.
I appreciate your help very much
Andrew
|
 |
 |
|