Question: I have a program I'm working on, rather starting, for a website that I have been making. The program is an HTML5 Canvas with JavaScript (and jQuery) game. To do this I have to be able to tell where in the canvas the user clicks. I could do it like this:

```
mouse = new Object();
mouse = {
   //Assign Temp Values 
   x: 0,
   y: 0,
   click: function(event) {
       //Code to get location and assign to mouse.x and mouse.y then handle click
   }
};

$(document).ready(function() {
    $('#canvas').click(function(evt) {mouse.click(evt);}); 
});

```

Or I could do it like this:

```
mouse = new Object();
mouse = {
    x: 0,
    y: 0
}

$(document).ready(function() {
    $('#canvas').click(function(evt) {
        //Code here to get location and assign to mouse.x and mouse.y and then handle click
    });
});

```

I know in this case that it is less code for the latter and I've seen questions like this for other languages but I was wondering if there are any advantages to using a method for event handling or a separate function in JavaScript. For example: one being good programming practice, or more efficient, or even easier to read. Any input would be appreciated.

Answer: 
[`lastInsertId()`](http://php.net/manual/en/pdo.lastinsertid.php) returns the identifier of the last row inserted *on that connection*, so concurrent users (with different connections to the database) will not interfere.
You can avoid this by doing a select by the email or some unique field. That will guarantee you get the correct user id.

For example:

```
select id from user_table where email = 'user@email.com' limit 1;

```