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

Popular posts from this blog

linux - Using a Cron Job to check if my mod_wsgi / apache server is running and restart -

actionscript 3 - TweenLite does not work with object -

jQuery Ajax Render Fragments OR Whole Page -