title: Symfony2 controller static variable
body: <p>In one of my controllers, I have some static variables and two actions: </p>
  
  <pre><code>class ChooseController extends Controller
  {
      private static $wholedata = array();                          
  
      private static $currentdata = array();                            
  
      private static $wholenum = 0; 
  
      private static $currentnum = 0;  
  
      public function choosefirstAction()
      {
           $company = $this-&gt;getUser()-&gt;getCompany();
           $em = $this-&gt;getDoctrine()-&gt;getManager();
  
           self::$wholedata = $this-&gt;getDoctrine()
           -&gt;getRepository('NeejobCompanyBundle:Selected')-&gt;findBy(
              array("company" =&gt; $company),
              array("job" =&gt; 'ASC')
           );
  
          self::$wholenum = count(self::$wholedata);
          self::$currentdata = array_slice(self::$wholenum, 0, 3);
          self::$currentnum = 3;
  
          return new response(json_encode(self::$currentdata));
      }
  
      public function choosemoreAction()
      {
          //... 
          return new response(self::$wholenum);
      }
  }
  </code></pre>
  
  <p>I still have <code>$wholenum = 0</code>, which is supposed to be 3 or larger. How should I handle the problem? </p>