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

Affected Row ID #1

Closed
chrislentz opened this issue Dec 12, 2010 · 1 comment
Closed

Affected Row ID #1

chrislentz opened this issue Dec 12, 2010 · 1 comment

Comments

@chrislentz
Copy link

I was just wondering how I might be able to adjust this class so when I INSERT something, the class returns something like the affected_row_id. In other words is it possible to add mysql_insert_id() functionality into the class?

It would be incredibly handy to know the generated row ID when inserting new data.

@ThingEngineer
Copy link
Owner

Sorry I let this go for so long, been busy on other projects. Plus I use CodeIgniter so I rarely use standalone db libraries like this except for in small projects. In answer to your question yes. This is actually what I'm doing now with the following code located on line 170 of the insert method.

($stmt->affected_rows) ? $result = $stmt->insert_id : $result = false;
return $result;

So IF there are affected rows then return the inserted id, IF not then return false. The included index file shows an example of inserting a record then prints out the inserted ID.

ThingEngineer pushed a commit that referenced this issue Feb 18, 2014
Calling reset should set values to null instead of unsetting them
ThingEngineer pushed a commit that referenced this issue May 24, 2014
Noneatme added a commit to Noneatme/PHP-MySQLi-Database-Class that referenced this issue Jul 8, 2016
avbdr pushed a commit that referenced this issue Jul 13, 2016
Syncing joshcam master
@GovetaXV GovetaXV mentioned this issue Jun 15, 2017
This issue was closed.
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

No branches or pull requests

2 participants