zen of coding

Set variable in the view to be used in the layout

I’m not sure that you should really be doing this, but I recall running into one situation where I wanted to set some variable in the view and have it available in the layout. Here’s how… In the view: $this->viewVars[‘myVar’] = ‘something’; In the layout: echo $myVar; Nate pointed out[…]

Read More »

New way to GROUP BY in CakePHP

Just recently ( end of May, 2008 ) there was an addition to CakePHP’s find method to easily build a GROUP BY in your SQL. If you’ve been using something like $this->Product->find(‘all’… etc., etc. Now you can add a new key ‘group’ to your find method, like so: $this->Product->find(‘all’,array(‘fields’=>array(‘Product.type’,’MIN(Product.price) as[…]

Read More »
%d bloggers like this: