How to define "global" find conditions for model in CakePHP? -
is possible define find conditions effective in controllers , functions use specific model?
for example if want return products in stock no matter what. maybe somewhere in model:
conditions => array('instock >' => 0)
i think try function on model, , call in controller simple line.
controller:
$productsinstock = $this->product->getproductsinstock();
model:
function getproductsinstock() { $produtcsinstock = $this->find('all', array('conditions' => array('instock >' => 0))); return $productsinstock; }
or try link, think help. don't know nothing callbacks: http://book.cakephp.org/view/1049/beforefind
Comments
Post a Comment