php - cakePHP is escaping field names, as strings, in BETWEEN condition -
cake escaping contract.start_date
, contract.end_date
, rendering query useless.
$this -> contract -> find('all', array( 'fields' => array(..), 'conditions' => array( 'now() between ? , ?' => array( 'contract.start_date', 'contract.end_date' ) ) ));
the problem query executed is
select <fields> monthly `contracts` `contract` now() between 'contract.start_date' , 'contract.end_date' #/* field names escaped , treated strings */
that's because query parameterization values (parameters), not fields. can't use ? tokens replace field names because, you've discovered, they're quoted if string values. (the same holds true database , table names well, how i've run against before , therefore know answer problem now, too.)
in case, want use 'now() between contract.start_date , contract.end_date'
.
Comments
Post a Comment