gautamlakum
gautamlakum

Reputation: 12015

cakephp compare database fields in find

I'm using CakePHP 2.1

I have following fields in database.

id
views
max_views

I want to fetch records which has views < max_views using find query. So what should be the query for it?

Thanks.

Upvotes: 1

Views: 2172

Answers (1)

grssnbchr
grssnbchr

Reputation: 2974

I'd do it like that.

$this -> find('all', array('conditions' => array('views < max_views')));

Upvotes: 6

Related Questions