This is my code
<?php
$object = SmEventModel::findFirst("EventNr = 19159");
$object->EventName = "test";
$object->update();
I paste the INSERT and SELECT.
When I used update() it always try to INSERT.
[2020-10-14T18:01:19+02:00][info] SELECT sm_event.BranchNr, sm_event.EventNr, sm_event.EventName, sm_event.EventDescription, sm_event.Eventcolor, sm_event.Eventfromdate, sm_event.Eventtodate, sm_event.CalendarNr, sm_event.ParentEventNr, sm_event.UserNr, sm_event.framecolnr, sm_event.backcolnr, sm_event.frametypenr, sm_event.timestamp, sm_event.status, sm_event.foreignlink, sm_event.foreignlinktype, sm_event.exclusive, sm_event.blocked, sm_event.templateId FROM sm_event WHERE sm_event.EventNr = 19159 LIMIT :APL0
[2020-10-14T18:01:19+02:00][info] INSERT INTO sm_event (BranchNr, EventNr, EventName, EventDescription, Eventcolor, Eventfromdate, Eventtodate, CalendarNr, ParentEventNr, UserNr, framecolnr, backcolnr, frametypenr, timestamp, status, foreignlink, foreignlinktype, exclusive, blocked, templateId) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)
This is my table view
<?php
public function initialize()
{
$this->setSource("sm_event");
$this->hasMany('EventNr', 'App\Models\SmEventitems', 'EventNr', ['alias' => 'smEventitems']);
}
I want to update and he always try insert and its the reason why I get the error
"SQLSTATE[23000]: Integrity constraint violation: 1062 Duplicate entry '19159' for key 'PRIMARY'"