Git Product home page Git Product logo

Comments (4)

billywhizz avatar billywhizz commented on July 17, 2024

i've had a look at this and i can get around it by issuing a SELECT LAST_INSERT_ID() in the callback from the query but am not sure if i am guaranteed to get the correct result as another insert could theoretically be run before this on the same connection... no?

from mysql.

iamcal avatar iamcal commented on July 17, 2024

that call will return the last insert ID for this connection, so you need to be careful about contention

the actual insert_id, along with affected_rows is returned in the command success packet, so we should be able to pull it out.

ref: http://forge.mysql.com/wiki/MySQL_Internals_ClientServer_Protocol#OK_Packet

[edit] it's passed as part of the packet sent to the 'end' event on the query as packet.insertId. packet.affectedRows is also available

from mysql.

felixge avatar felixge commented on July 17, 2024

I just added an FAQ entry for this here: c5540bf

Let me know if you have more questions!

from mysql.

billywhizz avatar billywhizz commented on July 17, 2024

great - thanks felix

from mysql.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.