Cake needs the table to have a primary key, but this does not need to
be a auto-incrementing integer.

I have a model here for configuration, where the primary key is a
varchar.  All the model has is

class AppConfig extends AppModel
{
        var $name = 'AppConfig';
        var $primaryKey = 'title';
        var $useTable = 'configuration';
}

and this works fine using the title primary key (INSERT / UPDATE as
appropriate).  This is using Cake 1.2.x, almost the latest trunk
(update every week or so).


On Oct 18, 11:53 pm, majna <[EMAIL PROTECTED]> wrote:
> How to save model with Model->save() when Primary key is not
> auto_increment?
> Model->create() and $this->Model->id=null wont work here.
>
> Example:
> Table Statuses
>
> PK code
> text
> description
>
> Statuses : primaryKey = 'code':
>
> Model->save() always do UPDATE ?!
> Becouse there is in Add view input Model/code.


--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "Cake 
PHP" 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