Hacktoberfest 2026: những issue maintainer đã đánh dấu cho tháng Mười, đang mở và phù hợp người mới. Xem issue Hacktoberfest

Dev: Make getInsertID() more consistent with save()

Đang mở
#9,233 4 bình luận 1 reaction 0 người được giao Xem trên GitHub

Maintainer thường phản hồi trong vòng 1 ngày

Chưa có ai nhận issue này.

Đánh giá

Độ khó
4/5
Thời gian dự kiến
3-5 ngày
Mức phù hợp với người mới
38/100
Loại issue
Tính năng
Độ rõ ràng
Khá rõ ràng
Mức độ hoạt động
Đình trệ
Công nghệ
mariadb, php
Lĩnh vực
backend, database

Hướng nghiên cứu

Đọc chuỗi thảo luận trên diễn đàn, sau đó so sánh hành vi của System Model đối với save(), insert(), update() và getInsertID(). Xác nhận ngữ nghĩa ID bị ảnh hưởng được dự định trước khi thay đổi bất kỳ điều gì; được xem là hoàn tất khi save() cung cấp nhất quán ID mong đợi cho cả đường dẫn insert và update, với coverage cho từng đường dẫn.

Do mô hình lập chỉ mục viết ra từ nội dung của issue.

Mô tả

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.

Ngôn ngữ chính
PHP
Star
6k
Fork
2k
Merge trung bình
1 ngày 22 giờ
Pull request đã merge (30 ngày)
59

Chuẩn bị môi trường

Bắt đầu từ đâu

  1. Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
  2. Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
  3. Fork repository và làm thay đổi trên một nhánh.
  4. Mở pull request có tham chiếu số hiệu của issue.

Issue khác của codeigniter4/CodeIgniter4

Tất cả issue của codeigniter4/CodeIgniter4

Issue tương tự

Thêm issue về PHP

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.