zen of coding

read() vs find()

What exactly is the differednce between $this->User->read() and $this->User->find()? Seemingly, they both retrieve the data (and possibly associated data) for the User model. Yet, there is a an important distinction: read() will also set the data for your model object, while find() will simply return the resultset array. What’s the[…]

Read More »

Changes to database config keys in RC1

There are a few important changes in the database configuration, which I wanted to quickly point out: 1. ‘connect’ key is gone. For example, if you had ‘connect’ => ‘mysql_connect’ you will need to replace it with ‘driver’=>’mysql’ 2. New key: ‘persistent’=>false This one is very important and you definitely[…]

Read More »

Validating a checkbox in CakePHP 1.2

In a few simple words: use the ‘comparison’ rule to validate a checkbox. To give you an example, let’s say a user needs to agree to the terms of service when registering a new account. In your User model you setup a rule for the checkbox as follows:  ‘agree’ =>[…]

Read More »

15 Essential CakePHP Tips

Note, this article was written a long time ago for CakePHP version 1.x … many of the points described here still apply in the latest 2.x versions of CakePHP. 1. Save() does not work! Sometimes it happens that save() fails without any obvious reason. Your data array looks fine and[…]

Read More »
%d bloggers like this: