In the controller, put this piece of code:
$this->paginate = array('order' => 'Topic.created DESC');
$this->set('topics', $this->paginate(array('Topic.board_id' => $id)));

In the controller, put this piece of code:
$this->paginate = array('order' => 'Topic.created DESC');
$this->set('topics', $this->paginate(array('Topic.board_id' => $id)));

https://trac.cakephp.org/ticket/2595
I found this when I was searching for a reason that the created and modified fields were not automagically saving when I saved a record to the database.
What is says is that instead of defining the created and modified fields as NOT NULL, they should be defined as NULL and let Cake then go ahead and put an entry into them. This is for version 1.2
Use
`modified` datetime default NULL,
instead of
`modified` datetime default NOT NULL default '0000-00-00 00:00:00',

In the function checkSession which is in the appController
function checkSession() {
// If the session info hasn't been set...
if (!$this->Session->check('User')) {
$this->Session->write('login_referrer',$this->params['url']['url']);
// Force the user to login
$this->redirect('/users/login');
exit();
}
}
And in the login() function in the user controller we place the follow code:
if ($success) {
if ($this->Session->check(’login_referrer’)) {
$loginReferrer = $this->Session->read(’login_referrer’);
$this->Session->delete(’login_referrer’);
$this->redirect($loginReferrer);
return true;
}
// the line before is the original redirect code
$this->dAuth->redirect(’login_success’);
return true;
}

The idea behind this blog is to keep a record of all the things that I learn while using CakePHP. I have been using it for about 2 months now and I have come across some great resources. My main problem is trying to remember where I saw how to do something. So to rectify that problem, I will keep them all here in a central (for me) location.