<?php
class User extends AppModel {
var $name = 'User';
var $displayField = 'fname';
}
How can I only return users from this model that have a “standing” of “1”? I am not looking to do this from the controller but, from the model.
[Solution] In model
function beforeFind($queryData){
$queryData['conditions']['standing'] = 1;
return $queryData;
}
The easiest way to do this would be to put in some filtering conditions in your
beforeFindcallback. Modifying the$queryDatavariable and adding your restriction to theconditionskey should do it.From the manual entry – http://book.cakephp.org/1.3/en/view/1049/beforeFind