How do I update primary key?

Hello there,

I've noticed that I cannot update primary key.

$robot = Robots::findFirstById(654321); $robot->setId('123456'); $robot->setName('newName'); $robot->update();

Nothing happens, update() method returns true, but nothing happens in database. If I remove the part where I set ID, or I set ID to 654321, name gets updated.

Any thoughts, @Phalcon?

Thanks!

edited Jun '14

I think to do this, you'll have to either use raw SQL, or do something like this:

$robot = Robots::findFirst(654321); 
$robot->setId(123456); 
$robot->setName('newName'); 
$robot->save();
Robots::findFirst(654321)->delete();

That is, create a new record and delete the old one.

If you are wanting to make a duplicate then you can:

    $robot = Robots::findFirst(654321)->toArray(); 
    $robot['id'] = 123456; 
    $robot['name'] = "newName"; 
    $newRobot = new Robot();
    $newRobot->create($robot);

Sorry if I've missed the point.