After saving data from the chats controller to the chat model, I want to add the last id of this chat item to another database table called issues. I do this from the ChatsController:
// Get last inserted id from Chat
$lastid = $this->Chat->getLastInsertId();
// Set the issue id to be updated
$this->Chat->Issue->id = $issueid;
// Update Issue table
$this->Chat->Issue->saveField('chat_id', $lastid);
Where I want to update Issue database item with id $issueid and add $lastid to field Issue.chat_id. $issueid is set before and is present and I am assuming $lastid is also set.
In both the issue and chat model, the models are belonging to the other.
What am I doing wrong that a new line is inserted in the issue database table instead of updating the correct one?