Switch branches/tags
Nothing to show
Find file History
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
..
Failed to load latest commit information.
lookupable.php
readme.textile

readme.textile

CakePHP Lookupable Behavior

A CakePHP behavior to easily look up the id’s of records or create them if they do not exist yet. Useful when working with lots of lookup / status tables.

Installing

1. Copy lookupable.php to app/models/behaviors/
2. Open / create app/app_model.php and add the following:


class AppModel extends Model{
	var $actsAs = array('Lookupable');
}

Usage / Docs

To lookup the id of lets say your ‘Admin’ group, you can simply do:


$group_id = $this->Group->lookup('Admin');

If the group does not exist yet, the behavior will automatically create it and return the id of the newly created record.

Known Bugs

None