zen of coding

Example of CakePHP's Containable for deep model bindings

Here’s an example of using the Containble behavior when you’ve got deep and complex model relationships. Let’s consider the following model associations… User->Profile User->Account->AccountSummary User->Post->PostAttachment->PostAttachmentHistory->HistoryNotes User->Post->Tag It’s very possible that each of those models has other associations, so we need to use Containable to retrieve just the models we need[…]

Read More »

Example of many nested conditions in CakePHP's find()

Just a quick example on how you can use deep, complex find conditions with OR, AND and NOT arrays in one shot… We need to get a list of all companies, where: Company.name is either ‘Future Holdings’ OR ‘Steel Mega Works’ AND we need to ensure that Company.status is either[…]

Read More »

find(‘list’) with three (or combined) fields

Update 01/07/2010: Good news everyone, for those switching over to cake 1.3, there is a great new feature: http://book.cakephp.org/view/1608/Virtual-fields ————– How about a little trick to extend the find(‘list’) functionality?.. Let’s say we need to display a list of users, but instead of just User.id and User.name we need to[…]

Read More »
%d bloggers like this: