suggest to change the position of the parameters of the update in class Model |
I think, when i use update(), I always need to set the data, but not use the primary key every time. So suggest to change the position of the parameters from
public function update($id = null, $data = null) to public function update($data = null, $id = null)
Hi, as this are a breaking change, it won't happen until version 5 as the soonest.
What kind of data are you putting in $data without and $id specified?
(05-28-2020, 10:55 AM)jreklund Wrote: Hi, as this are a breaking change, it won't happen until version 5 as the soonest.Sorry for so long time to reply. For example, in my case, I need to interface the third-part api, they have an unique id like "uuid", in my table, I defined id and uuid in the same table, then some sometimes they have some callback event or event push to my server with uuid. So I need to update my data like this: $uuid = $this->request->getPost('uuid'); $data = .... ; $room_model = new RoomModel(); $room_model->where('uuid', $uuid)->update(null, $data); The important things is, not all record's uuid field has value, so I can't use uuid to be the primary key
If you are doing all that, it would be better to just make a function in your RoomModel.
PHP Code: function updateByUUID(string $uuid, $data) |
Welcome Guest, Not a member yet? Register Sign In |