Gokulan
Gokulan

Reputation: 11

use arithmetic find conditions on cakephp

i need to convert following mysql condition to Cakephp find condition.

select * from bookings where (check_out_date - check_in_date) <=600 ;

Please help me.

Upvotes: 1

Views: 148

Answers (2)

BadHorsie
BadHorsie

Reputation: 14544

$this->Booking->find('all', array(
    'conditions' => array(
        '(Booking.check_out_date - Booking.check_in_date) <=' => 600
    )
));

Upvotes: 2

Dipesh Parmar
Dipesh Parmar

Reputation: 27364

try following code and debug it.

$bookings = $this->Booking->find('all',array
(
    'conditions' => array
    (
        '(Booking.check_out_date - Booking.check_in_date) <=' => 600
    ),
    'fields' => array
    (
        'Booking.*'
    ),
    'recursive' => -1
));

above code is tested and work like a charm.

Upvotes: -1

Related Questions