Suppose that the primary key of your table is "somekey" in varchar type. And
your model is SomeModel
In the define of SomeModel (somemodel.php), use the code:
$primaryKey = 'somekey';
In your add action, if you primary key's value is unique and randomized, use
this:
if($this->data)
{
$this->data['SomeModel'][$this->SomeModel->primaryKey] = 'your key value';
}
Else, if the value of primary key is submit from you form. You dont need to
do any thing.
---------------------------------
Best regards !
Giang Son Dat
Mobile: +84 988114164
Email [email protected], [email protected]
On Sun, Mar 8, 2009 at 6:52 PM, brian <[email protected]> wrote:
>
> On Sun, Mar 8, 2009 at 9:14 PM, James K <[email protected]> wrote:
> >
> > You can't. All cake models must have an auto-incremented numeric
> > primary key called "id".
>
> Not true. You can override the default name by setting $primaryKey in the
> model.
>
> I was under the impression that it also didn't have to be an
> auto_increment/serial column but I might be wrong about that. Anyone
> know the score on that?
>
> > Even if you weren't using Cake, making a non-numeric, user editable
> > primary key is generally a very bad idea...
>
> I'll second that.
>
> >
>
--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---