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

php - How can I edit my code to echo the data of child's element where my search term was found in, in XMLReader? -

javascript - Iterate over array and calculate average values of array-parts -

jQuery Ajax Render Fragments OR Whole Page -