Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Access to model's last inserted ID #1440

Merged
merged 1 commit into from
Nov 11, 2018

Conversation

nowackipawel
Copy link
Contributor

Description
Allows to get insertID after insert($insert_data, false) which returns CodeIgniter\Database*\Result object instead of insertID.

Allows to get insertID after insert($insert_data, false) which returns CodeIgniter\Database\*\Result object instead of insertID.
@jim-parry
Copy link
Contributor

There is an insertID() provided in Database\BaseConnection. Can it be used instead of a new method, with a different accessor style (getInsertID vs insertID)?

@nowackipawel
Copy link
Contributor Author

Ofc there is insertID() method in BaseConnection but BaseConnection is not accessible from outside of the model after insert is called with false as the 2nd parameter.

@jim-parry
Copy link
Contributor

Fair enough. It just struck me as odd, but makes sense now.

@jim-parry jim-parry merged commit eaa8487 into codeigniter4:develop Nov 11, 2018
@@ -551,6 +570,8 @@ public static function classToArray($data, string $dateFormat = 'datetime'): arr
public function insert($data = null, bool $returnID = true)
Copy link

@atefBB atefBB Apr 6, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this feature (returning inserted row ID with $returnID flag) isn't well documented! Need to be documented.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants