• 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Model's save method should scan for existing row

#1
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.
Reply

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


Digg   Delicious   Reddit   Facebook   Twitter   StumbleUpon  


  Theme © 2014 iAndrew  
Powered By MyBB, © 2002-2020 MyBB Group.