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

get last_insert_rowid #43

Closed
QuickBrownFoxy opened this issue Sep 19, 2013 · 5 comments · Fixed by #110
Closed

get last_insert_rowid #43

QuickBrownFoxy opened this issue Sep 19, 2013 · 5 comments · Fixed by #110

Comments

@QuickBrownFoxy
Copy link

I can seem to find any method returns last_insert_rowid(), do I need to get it with raw query?

I need to use "last_insert_rowid" because i am trying to populate database at first run from a text file and there is ID relation of items

Thanks

@satyan
Copy link
Collaborator

satyan commented Sep 19, 2013

Yes, there's no specific function right now to give you the last insert row_id.. You could try with raw query.
If you're inserting via Sugar, each insert returns the id of the corresponding record. That way you could also find out the id of the last record inserted.

Hope it helps. Let me know if you need more details.

@QuickBrownFoxy
Copy link
Author

Is it the .save() function returning I'd? Sorry away from pc can't check atm

@satyan
Copy link
Collaborator

satyan commented Sep 19, 2013

Yes.

@QuickBrownFoxy
Copy link
Author

.save() returns void
but I can use getId() after save

@satyan
Copy link
Collaborator

satyan commented Sep 20, 2013

Yeah. My bad. It doesn't return the id, it sets the id field in the object. As you mentioned, you could use getId() after that.

You could modify the save method to return the id if you need that too..

Hope it helps.

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 a pull request may close this issue.

2 participants