title: node-mysql where does connection.end() go
body: <p>I am really confused with using connection.end() in node-mysql.</p>
  
  <p>I don't fully understand where it goes, at the moment i place it after a query but then if i create a new query i get an error <code>Cannot enqueue Query after invoking quit.</code></p>
  
  <p>Now my app has a bunch of checks going here is one of them:</p>
  
  <pre><code>   socket.on('connect', function(data,callBack){
         var session = sanitize(data['session']).escape();                    
  
         var query = connection.query('SELECT uid FROM sessions WHERE id = ?', [session],
             function(err,results){
             if(err){ 
                    console.log('Oh No! '+err);                   
                }else{
                    io.sockets.socket(socket.id).emit('connectConfirm',{data : true});
                }
                connection.end();
             });
     });
  </code></pre>
  
  <p>Now after that if i have any other query i get the error occuring.</p>
  
  <p>I made a more informed explaination in my jsFiddle: <strong><a href="http://jsfiddle.net/K2FBk/" rel="noreferrer">http://jsfiddle.net/K2FBk/</a></strong> to better explain the problem I'm getting. The documentation for node-mysql does not totally explain the correct place to put <code>connection.end()</code></p>
  
  <p>Where should it go to avoid this error?</p>