Update Primary Keys

Hi All,

i'm getting in trouble with updates for primary keys. Since ORM uses pk to identify its counterpart record, to determine what to update, if I try to update a PK of an object, Phalcon updates the other, if the record does exist.

How can I tell ORM the current and the new pk?

Thanks Gianluca


The ORM implements the active record pattern in which an object instance is tied to a single row in the table. Mutating the primary key leads to modify the row on which the object ties to, in a completely different one which itself violates the pattern implementation consistency.

I think you can use the database layer to perform these updates if you still need it. http://docs.phalcon.io/en/latest/reference/db.html


Thanks Phaclon for the suggestion, i'll have a try.

edited Dec '14

What about for Natural Keys? Like this table:




genre VARCHAR(45)

created_at TIMESTAMP

updated_at TIMESTAMP


genre is the natural key (making it the primary key). But it needs to be updatable. Would this fit a different mold/mindset?



I'm quiet sure that without INT primary key you want be able to use phalcon ORM. But db layer will be still useable.