On Sun, Mar 8, 2009 at 10:02 PM, Son Dat Giang <[email protected]> wrote:
> 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.

I've just been going through the source and I'm pretty sure that this
wouldn't work. For starters, setting the PK in $data would mean not
getting the 'created' field automatically  filled. I guess that could
be done manually, as well.

But, there would be problems with lastInsertId. With the MySQLi
driver, for instance, this uses LAST_INSERT_ID() which is reliant upon
an auto_increment field. Unless I've read this incorrectly, it looks
like the PK must be auto_increment/serial. It looks like the only
possible change from the convention is setting an alternative name
with $primaryKey, not in the type of column.

--~--~---------~--~----~------------~-------~--~----~
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