I’m new to cakePHP and I need to use the controller::postConditions method with the BETWEEN operator but I can’t figure out how.
I tried this syntax, as I have read on the controller::find documentation :
$this->postConditions($this->data, array('Client.client_date_inscription BETWEEN ? AND ?'=>array($this->data['Client']['client_date_inscriptionD'],$this->data['Client']['client_date_inscriptionF'])))
the form input is created like so :
echo $form->input('Client.client_date_inscriptionD',array('label'=>false,'type'=>'text','class'=>'toDatePicker'));
but this throws this error :
SQL Error: 1054: Unknown column 'Client.client_date_inscriptionD' in 'where clause'
So my question is, how do you use the BETWEEN operator with postConditions ?
@boobyWomack I changed the uppercase D and F, it’s something I’ve tried randomly.
I tried many things and lurked in the cookbook to find the answer.
I found how to do this by chance actually, not in the postConditions doc.
Here’s the postConditions call :
However, the Client.client_date_inscription input in the view should provide an array of 2 values.
I did it with a syntax I’ve found in the cookbook :
Another way is to change manually the value of
$this->data['Client']['client_date_inscription']in the controller, but that wasn’t relevant in my case.Hope this helps anyone with the same issue, since it’s not very clear in the cookbook nor in the API.