Skip to content

feat: add Model::firstOrInsert() with failure handling#10012

Open
michalsn wants to merge 5 commits intocodeigniter4:4.8from
michalsn:feat/first-or-insert
Open

feat: add Model::firstOrInsert() with failure handling#10012
michalsn wants to merge 5 commits intocodeigniter4:4.8from
michalsn:feat/first-or-insert

Conversation

@michalsn
Copy link
Member

Description
This PR adds Model::firstOrInsert(), which finds the first row matching the given $attributes, or inserts a new row using the merged result of $attributes and $values. Both parameters accept an array, stdClass, or an Entity.

Closes #5163

Checklist:

  • Securely signed commits
  • Component(s) with PHPDoc blocks, only if necessary or adds value (without duplication)
  • Unit testing, with >80% coverage
  • User guide updated
  • Conforms to style guide

@michalsn michalsn added enhancement PRs that improve existing functionalities 4.8 PRs that target the `4.8` branch. labels Feb 27, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

4.8 PRs that target the `4.8` branch. enhancement PRs that improve existing functionalities

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants