php - Yii Creating an audit trail; Controller to another Controller -


i'm creating audit trail module project using yii php, , i'm quite newbi.. , know audit trail concerned creation of history, transaction logs... i've created model audit trail , generated controller separate model it. (using gii of course)

my problem lies how create entry , or trail (log, history, don't know term sorry =3)

i have audittrailcontroller action:

class audittrailcontroller extends controller{      public function actioncreate()     {     //do create trail        }  } 

my plan call actioncreate() every other controllers on modules in whole project say:

class studycontroller extends controller {          public function addrecord(){         //add record           //---> want call acioncreate() audittrailcontroller here         //to create entry telling user "user" @ time "time"         //performed "add" operation..         }          public function updaterecord(){         //update record           //---> want call acioncreate() audittrailcontroller here         //create audit entry telling user "updated"         }  } 

-the yii:app() doesn't trick..(or ive used wrongly)..

i've searched many answers it's "evil" call controller one..i saw terms using component..other should done in model... have no idea.. i'm new in oop , yii i'm in struggle here.. me out thanks.. if above possible sample code helpful thanks!

you can call action in controller in way

//here controller action

class audittrailcontroller extends controller {      public function actioncreate()     {     //do create trail        }  } 

//here controller want use action

class studycontroller extends controller {          public function addrecord(){                $controller = new audittrailcontroller($this->id);                $controller->actioncreate();         } } 

and don't forget add config line import

    'application.controllers.*', 

Comments

Popular posts from this blog

blackberry 10 - how to add multiple markers on the google map just by url? -

php - guestbook returning database data to flash -

delphi - Dynamic file type icon -