Ok, so in classic n00b goodness I found my simple mistake.
I think the convention is to have your primary key of a table be
labeled `id` and I decided to go for broke naming it `user_id`
To correct my problem I needed to tell the User model I'm using the
`user_id` field as the primary key:
<?php
class User extends AppModel {
var $name = 'User';
var $primaryKey = 'user_id';
}
?>
Viola, problem solved. Thanks for the quick response!
-Andy
On May 13, 1:05 pm, Aaron Shafovaloff <[EMAIL PROTECTED]> wrote:
> Shouldn't it be...
>
> $this->User->id = $data['User']['id'];
>
> ?
>
> On May 13, 10:27 am, theandystratton <[EMAIL PROTECTED]>
> wrote:
>
> > To preface, I've seen this a few places before but the solutions given
> > aren't getting me anywhere.
>
> > I've got a basic User model extending AppModel, I'm finding a record
> > based on the matching the data in 2 fields, changing 1 field in the
> > returned array and trying to save (update) that record by sending the
> > array back to the save method...
>
> > // start code:
>
> > $data = $this->User->find( array('User.username' => $username,
> > 'User.email' => $email) );
>
> > $data['User']['passwd'] = $this->Auth->password('test');
>
> > //
> > // problem occurs with or without following line:
> > // $this->User->user_id = $data['User']['user_id'];
> > //
>
> > $this->User->save( $data );
>
> > // end of code.
>
> > This results in an attempt to insert a new record with the user_id in
> > $data.
>
> > Any help is appreciated, I've migrated into Cake this week and am
> > trying to convert an existing procedural app to it.
>
> > -andy
--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---