I'm struggling to grasp how data is updated (not inserted) with Cake.
I can create new records just fine, but now I'm trying my first update
and I can't get it to work. Moreover, it might be a special case,
since it's an Auth user and there's no "id", per se.

In my login() method, I'm checking whether authentication was
successful and, if so, I'd like to set and update the last_login field
with the current timestamp:

        public function admin_login() {
                $this->pageTitle = 'Administrator Login';

                if ( $this->Auth->user() ) {
                        $user = $this->Auth->user();

                        $user['Administrator']['last_login'] = date ( 'Y-m-d 
H:i:s' );
                        $this->Administrator->save ( $user );

                        $this->set ( 'auth', $this->Auth->user() );

                        $this->redirect ( array (
                                'controller' => 'administrators',
                                'action'     => 'index',
                                'admin'      => true
                        ) );
                }
        }

My user model is Administrator with email and password fields rather
than the defaults. These deviations are configured in my
AppController. Since there's no "id" field, I can't use the $this-
>Model->id notation in before the save() call (that just throws a
field not found error), nor can I modify it to use email since "email"
is my primary key.

What's the right way to do this?

Thanks.
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"CakePHP" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to 
[email protected]
For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to