dornad
dornad

Reputation: 1294

PHP Error in CakePHP

I have the following code in a CakePHP Controller:

var $searchCondition = array(
    'Item.date >' => date('Y-m-d', strtotime("-2 weeks"))  // line 11
);

var $paginate = array(
    'conditions' => $itemCondition,
    'limit' => 25,
);


function index() {
    $this->set('applications',$this->paginate());
}

I am getting the following error:

Parse error: syntax error, unexpected '(', expecting ')' in D:\xampplite\htdocs\myApp\app\controllers\applications_controller.php on line 11

Does anyone knows what it means? I've double checked and the syntax seems to be right.

Thanks

Upvotes: 0

Views: 117

Answers (1)

deceze
deceze

Reputation: 521995

You can only use constant values when initializing class properties. You cannot use functions here. You'll have to do something like this:

var $searchCondition = array(
    'Item.date >' => null
);

function beforeFilter() {   // or __construct
    $this->searchCondition['Item.date >'] = date('Y-m-d', strtotime("-2 weeks"));
}

Upvotes: 2

Related Questions