In CakePHP/2.x, the prepared statements implementation allows to bind parameters in conditions
:
'conditions' => array(
'dob < ? + INTERVAL 1 DAY' => $dob,
);
Is there a syntax to do the same in fields
?
I’ve tried several ideas but none worked. For instance, this:
'fields' => array(
'? + INTERVAL 1 DAY AS next_day' => $dob,
);
… just generates expressions like
`MyModel`.`2012-05-15`
… because it ignores the key and it assumes the value is a column name.
My current workaround is escaping with DboSource::value()
but it’s of course not as nice as prepared statements:
// Inside model:
'fields' => array(
$this->getDataSource()->value($dob) . ' + INTERVAL 1 DAY AS next_day',
);