Track Controller And Action

Hi, I want to track what the users did in the system.

So I write this in my controller:

protected function beforeAction($action) {




		if (!Yii::app()->user->isGuest) {

			$monitor = new Monitor;

			$monitor->user_id = Yii::app()->user->id;

			$monitor->controllor = $this->id;

			$monitor->action = $action->id;

			$monitor->create_at = date('Y-m-d H:i:s', time());




		return true;



In this way, I can store info about controller and action, but this is not enough. I also need to store params from request of post and get and other params, for instance:

//how to get '24'?




    data: {id: id},




//how to get 'id'?

All the parameters should be in $_GET or $_POST ;)

You could use that:


foreach ($_REQUEST as $key=>$val) {

//for secure issues

$yourdataName = ‘mydat’.$n;

$yourdataValue = ‘myval’.$n;

$monitor->$yourdataName= $key;

$monitor->$yourdataValue= $val;



//if you have to read the above parameters

the key


and the respective value is in



the way that i can imagine to get data is below, but:

if(isset($_POST['?name?']))  //there are too many different 'name' in the request process, how can i know which the 'name' is?

    // do-sth


i ll try.

many thanks :)