Archive for November, 2009

This is quite handy if you’re working in a team and you don’t want the designer/client poking about in the controllers to set page titles. You can set them in the view using this code:
1<? $this->pageTitle = ‘My page title’ ?>

To add a directory without any of its contents/files to SVN you can do this:
(You need to be using SVN v1.5 or greater for this to work)
1svn add –depth=empty app/tmp
You can then SVN ignore the contents to prevent it being version controlled.

Quick reminder for myself of how to do a nested MySQL query with the nested statement in the parent where clause:
12345678910$sql = <<<SQL
SELECT id
 FROM invoices as Invoice
 WHERE id NOT IN (
  SELECT parent_id
  FROM invoices
  WHERE parent_id > 0
  GROUP BY parent_id    
 ) AND billing_start <= ‘$end’
SQL;

I’ve been using the containable behavio(u)r in CakePHP along with the $recursive = -1 property in my models to cut down on the amount of SQL querying going on.
I needed to specify a second level recursion on one of my associated models and managed it by doing this:
12345$this->paginate[’Invoice’][’contain’] = array(
    ‘Order’ => ‘OrderedProduct’,
    [...]

If you wanted to manipulate elements you’d added to a page with jQuery after the DOM had loaded, you used to have to specify event handlers when adding them.
jQuery v1.3 has a handy new ‘live’ method. Which basically allows you to access all elements, whether present at page load or added dynamically afterward with jQuery.
jQuery [...]

If you use the CakePHP Auth component and you need some conditions for users attempting to login, you can set this attribute/property in the Auth object:
1$this->Auth->userScope = array(’User.status’ => 1);
The userScope attribute behaves pretty much like an Active Record find condition definition.
So in the above example, only users with a status of 1 (active) can [...]

Tried to do a schema snapshot of my db today (cake schema generate) to throw in SVN. I’d added an enum column to one of my tables and it threw this error:
1Notice: Schema generation error: invalid column type enum(’flat_fee’,'per_unit’) does not exist in DBO in /vhosts/site.com/accounts/cake/libs/model/schema.php on line 475
Enum must be too old-school and crusty [...]


top