codeigniter4 / codeigniter4/CodeIgniter4
Dev: Make getInsertID() more consistent with save()
- Langage dominant
- PHP
- Étoiles
- 6k
- Forks
- 2k
- Merge moyen
- 1 j 11 h
- PR mergées (30 j)
- 73
Description
### PHP Version
8.2, 8.3
### CodeIgniter4 Version
latest
### CodeIgniter4 Installation Method
Composer (using `codeigniter4/appstarter`)
### Which operating systems have you tested for this bug?
macOS, Linux
### Which server did you use?
fpm-fcgi
### Database
MaraiaDB
### What happened?
Not exactly a bug, but not really a FR either. See this forum thread: https://forum.codeigniter.com/showthread.php?tid=91800&pid=421782#pid421782
Essentially I'm offering to PR a change to `\System\Model::update()` that would set an instance's `$insertID` property the same way `\System\Model::insert()` does so that the behaviour of `save()` is more consistent.
Currently `\System\Model::getInsertID()` only returns a value if a `save()` does an insert. The logic needed to handle that works against the elegance provided by `save()`.
### Steps to Reproduce
Use `\System\Model::save()`
### Expected Output
Best case, `\System\Model::getInsertID()` will return the "affected ID" after `\System\Model::save()` regardless of which action occurred.
### Anything else?
I'm stoked contribute to core, but I didn't want to spend the time on a PR if there is no desire to change this behaviour. Please advise.
I can write the update to the docs too if I'm pointed in the right direction to do so.
Guide de contribution
Ouvrir le guide de contribution
Piste de recherche
Lisez le fil du forum, puis comparez le comportement de System Model pour save(), insert(), update() et getInsertID(). Confirmez la sémantique attendue de l’ID affecté avant de modifier quoi que ce soit ; le travail est terminé lorsque save() expose systématiquement l’ID attendu pour les chemins d’insertion et de mise à jour, avec une couverture pour chacun d’eux.
Rédigé par le modèle d'indexation à partir du texte de l'issue.
Évaluation
- Stack technique
- mariadb, php
- Domaine
- backend, database
- Type d'issue
- Fonctionnalité
- Difficulté
- 4/5
- Temps estimé
- 3-5 jours
- Activité
- À l'abandon
- Clarté
- Plutôt claire
- Accessibilité débutants
- 38/100