Welcome Guest, Not a member yet? Register   Sign In
Model's save method should scan for existing row

save method was supposed to simplify logic to choose between insert/update, by scanning if row exist on the table or not. But as of right now, CodeIgniter 4.0.4, it only scans if table's primary key was mentioned on the input parameter.

So it will get confused when I want to insert a new data into a row with the primary key included. It will choose to update the data, because of the primary key which was included in the data, but fail to do so as the data itself is not there in the first place.

So I thought save method should look if inputted data was on the table to decide which method to use afterwards, insert or update.

(This post was last modified: 08-26-2020, 06:04 AM by MGatner.)

If you have a specific primary key but you know you want to create a new record, why not use insert()?

Theme © iAndrew 2016 - Forum software by © MyBB