Web Images Videos Maps News Shopping Gmail more »
Recently Visited Groups | Help | Sign in
Google Groups Home
Write to log table for every successful update/delete
There are currently too many topics in this group that display first. To make this topic appear first, remove this option from another topic.
There was an error processing your request. Please try again.
flag
  9 messages - Collapse all  -  Translate all to Translated (View all originals)
The group you are posting to is a Usenet group. Messages posted to this group will make your email address visible to anyone on the Internet.
Your reply message has not been sent.
Your post was successful
 
From:
To:
Cc:
Followup To:
Add Cc | Add Followup-to | Edit Subject
Subject:
Validation:
For verification purposes please type the characters you see in the picture below or the numbers you hear by clicking the accessibility icon. Listen and type the numbers you hear
 
satyavirya  
View profile  
 More options Jul 3, 12:18 pm
From: satyavirya <hendry....@gmail.com>
Date: Fri, 3 Jul 2009 09:18:23 -0700 (PDT)
Local: Fri, Jul 3 2009 12:18 pm
Subject: Write to log table for every successful update/delete
Hi guys, my app need to write into a log table for every successful
update/delete operation, my current approach is to put the code in
AfterFilter in AppController, the problem is, how do I get / know a
successful update/delete has been done?
Or is there any other suggestions to do this? Thanks.

    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Carlos Gonzalez Lavin  
View profile  
 More options Jul 3, 12:47 pm
From: Carlos Gonzalez Lavin <carloslavi...@gmail.com>
Date: Fri, 3 Jul 2009 11:47:20 -0500
Local: Fri, Jul 3 2009 12:47 pm
Subject: Re: Write to log table for every successful update/delete

I don't know if these applies to you... but saves (I don't know if just
valid ones) do a callback to the model's aftersave function (either inserts
or updates)

A bit more info on it:
http://book.cakephp.org/view/684/afterSave

2009/7/3 satyavirya <hendry....@gmail.com>


    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Hendry  
View profile  
 More options Jul 3, 12:58 pm
From: Hendry <hendry....@gmail.com>
Date: Sat, 4 Jul 2009 00:58:15 +0800
Local: Fri, Jul 3 2009 12:58 pm
Subject: Re: Write to log table for every successful update/delete
Hi Carlos,

Yes, I can use the model's callback method (aftersave and afterdelete)
but then, since this would require writing to another table, which
means call to other model from inside a model, wouldn't this break the
MVC pattern?

Regards,
Hendry

On Sat, Jul 4, 2009 at 12:47 AM, Carlos Gonzalez


    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Braindead  
View profile  
 More options Jul 3, 5:44 pm
From: Braindead <markus.he...@gmail.com>
Date: Fri, 3 Jul 2009 14:44:15 -0700 (PDT)
Local: Fri, Jul 3 2009 5:44 pm
Subject: Re: Write to log table for every successful update/delete
You should write a behavior. I guess that's the way to go. :-)

    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Miles J  
View profile  
 More options Jul 3, 5:48 pm
From: Miles J <mileswjohn...@gmail.com>
Date: Fri, 3 Jul 2009 14:48:20 -0700 (PDT)
Local: Fri, Jul 3 2009 5:48 pm
Subject: Re: Write to log table for every successful update/delete
Why?

If anything log to text files.


    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
BlueC  
View profile  
 More options Jul 3, 6:25 pm
From: BlueC <messageforch...@googlemail.com>
Date: Fri, 3 Jul 2009 15:25:38 -0700 (PDT)
Local: Fri, Jul 3 2009 6:25 pm
Subject: Re: Write to log table for every successful update/delete
You could use the logablebehavior I have used it and it is really
excellent!! It even integrates with auth component so you can log and
see who did what. It can also log inserts too.

http://code.google.com/p/alkemann/wiki/LogableBehavior
http://bakery.cakephp.org/articles/view/logablebehavior

Enjoy!

Chris

On Jul 3, 5:18 pm, satyavirya <hendry....@gmail.com> wrote:


    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Paul  
View profile  
 More options Jul 4, 12:20 am
From: "Paul" <s...@webprogression.co.nz>
Date: Sat, 4 Jul 2009 16:20:59 +1200
Local: Sat, Jul 4 2009 12:20 am
Subject: RE: Write to log table for every successful update/delete


    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Paul  
View profile  
 More options Jul 4, 12:31 am
From: "Paul" <s...@webprogression.co.nz>
Date: Sat, 4 Jul 2009 16:31:04 +1200
Local: Sat, Jul 4 2009 12:31 am
Subject: RE: Write to log table for every successful update/delete
Aplogies gain for the double post, email issues.

Anyway... we do a lot of logging of record creation etc to the db for
various reasons and ideally a behavior is what your after, but for a quick
solution its easy enough to call the log model on the fly in your  model
callbacks like

function afterSave($created) {
        $action = $created ? 'create' : 'update';
        $Log =& ClassRegistry::init('Log');
        $Log->create();      
        $Log->save(array('action' => $action, 'model' => $this->name,
'foreignKey' => $this->id));

}

That's a pretty crude example but nothing wrong with doing it that way if it
fits your needs. If you were to be doing this in your app model to trigger
on all models, be sure to stop the callback on your log model save,
otherwise it will eternally log it self to death.

$Log->save(array('action' => $action, 'model' => $this->name, 'foreignKey'
=> $this->id), array('callbacks' => false));

HTH

Paul


    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Hendry  
View profile  
 More options Jul 4, 3:49 pm
From: Hendry <hendry....@gmail.com>
Date: Sun, 5 Jul 2009 03:49:08 +0800
Local: Sat, Jul 4 2009 3:49 pm
Subject: Re: Write to log table for every successful update/delete
THanks Chris, I'm testing it now ;)

Regards,
Hendry


    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
End of messages
« Back to Discussions « Newer topic     Older topic »

Create a group - Google Groups - Google Home - Terms of Service - Privacy Policy
©2009 Google