Controller Static Property problem...


I am facing a problem using the static properties of a Controller Class. I declared a static property because I want to keep the ordering criteria when we reload the page, I thought if I save it in a Static property then I won’t loose it everytime I reload the page because it is supposed to be the same no matter what instance of the CommentController. So here is what I used:

class CommentController extends MyController


        public static $order;


        public function actionComment(){



                $this::$order = $_GET['order'];

            $model->order = $this::$order;




But everytime I reload the page the Static Properties gets back to NULL. If I give it a value in one of the instance of the CommentController, shouldn’t it be available as well in another instance of the same class after?

Maybe there is something I misunderstood about Static properties…

Thanks for any help!

you must come from some other language like java or …


in php the static variable can only be alive in request scope . if you do another request the first assignment is gone . so you can consider use session to solve your problem .

in java the static variable can be still there if the jvm not shut it can across request .

Oh what a pity… :) Thanks for this useful information, I will use session then!