-
Notifications
You must be signed in to change notification settings - Fork 8
Open
Description
One of my models is just keeping track of data in a third party service. The id field is set to theirs. Saving the model resets that id field to 0 because the insert_id is forced on it here:
| $this->setAttribute($this->idField, ee()->db->insert_id()); |
Instead of editing that I had just copied the method and removed that bit of code for that particular model, but while documenting it hit me a condition could be used there instead, save the insert_id if it is not zero.
E.g. instead of:
$this->setAttribute($this->idField, ee()->db->insert_id());
Perhaps change to (untested):
$this->setAttribute($this->idField, ee()->db->insert_id() ? : $this->getAttribute($this->idField)); // double-checked, shorthand ternary is okay since Channel-Data requires PHP 5.3+ anyways
Metadata
Metadata
Assignees
Labels
No labels