Created
February 6, 2014 12:09
-
-
Save cranic/8842937 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| pool.getConnection(function(err, connection){ | |
| console.log("PQP " + err); | |
| // Verifica que tipo de query quer ser executada | |
| if(tipo == 0) { | |
| console.log("Arruma a query..."); | |
| // Monta a query | |
| query = "SELECT id, tmpUf, tmpCidade, empresa, fotop, razao, token FROM fretebra_dedicado.empresas WHERE chatToken = '" + tokenE + "'" ; | |
| } | |
| console.log("Executa a query..."); | |
| // Executa a query... | |
| connection.query(query, function(err, rows){ | |
| console.log("Quase executando a query..."); | |
| if(err) { | |
| // Print teste | |
| console.log("Erro mysql..."); | |
| } else { | |
| // Print teste | |
| console.log("Resultado mysql: " + rows); | |
| // Se encontrou então retorna um array com as informações do cliente | |
| return new Array({ | |
| tokenE: rows[0].tokenE, | |
| socket: rows[0].socket.id, | |
| user: rows[0].id, | |
| nome: rows[0].empresa, | |
| logo: rows[0].fotop, | |
| cidade: rows[0].tmpCidade + "/" + rows[0].tmpUf , | |
| qtd_cargas: rows[0].cargas, | |
| tipo: rows[0].tipo, | |
| status: "online" | |
| });; | |
| } | |
| // Isso aqui faz com que a conexão entre em modo de espera, quando outro tentar acessar essa conexão ela é reativada, em vez de tentar outra conexão | |
| connection.release(); | |
| }); | |
| }.bind(this)); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment