In one of my controllers, I have some static variables and two actions:
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->getUser()->getCompany();
$em = $this->getDoctrine()->getManager();
self::$wholedata = $this->getDoctrine()
->getRepository('NeejobCompanyBundle:Selected')->findBy(
array("company" => $company),
array("job" => '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);
}
}
I still have $wholenum = 0, which is supposed to be 3 or larger. How should I handle the problem?
$wholenumisn't being stored anywhere