cakephp/cakephp — pull request #441 by pierredup (2012-01-24 07:55:40+00:00)
Title: Use Object for database results

I implemented an object for database results, instead of returning just an array.
The object implements ArrayAccess, so it is fulle backwards compatible.
The associations are loaded dynamically when you need them, so you don't have to select all related records at once.

E.G
The following query

```php
$posts = $this->Post->find('all');
```

will return a Record instance.
Then you can do the following:

```php
foreach($posts as $post)
{
// the following will return the content field
echo $post->content;
echo $post->getContent();
echo $post['content']
echo $post['Post']['content'];

// The following will return the associated data. As soon as calling any of the following, the db will be queried to get the associated data
echo $post->User->name;
echo $post['User']['name'];

// easily save records
// the following will all save the record with the changed data
$post->content = 'new content';
$post->save(); // will save the new content

$post->setContent('new content');
$post->save();

$post['content'] = 'new content';
$post->save();

$post['Post']['content'] = 'new content';
$post->save();

$post->User->name = 'new user';
$post->User->save();

// or you can delete any record
$post->delete(); // will delete the selected post
}
```