[英]node-webkit and mysql queries
I'm a newbie with node-webkit. 我是node-webkit的新手。 I'm trying to make a desktop app which connects to server, in my case, to WAMP local server and make queries with mysql module of node.js.
我正在尝试制作一个桌面应用程序,该应用程序连接到服务器(以我为例)到WAMP本地服务器,并使用node.js的mysql模块进行查询。
I have this (I'm spanish, so excuse if the name of the classes and variables are in my language): 我有这个(我是西班牙语,如果类和变量的名称是我的语言,请原谅):
var datos_utilizados = function(err, resultado){
if(err){
throw err;
}
var datos = $.parseJSON(resultado);
var largo = datos.length;
for(var i=0;i<largo;i++){
var pelicula = "<div class='pelicula'><div class='etiqueta'>"+datos[i].nombreProducto+"<br><br>"+datos[i].descripcionProducto+"<br>Precio: "+datos[i].precioProducto+"</div></div>"
$('#capsula').append(pelicula);
}
}
consulta(datos_utilizados);
function consulta(callback){
var mysql = require('../node_modules/mysql');
var conexion = mysql.createConnection({
host: 'localhost',
user: 'root',
password: '',
database: 'prueba'
});
conexion.connect();
conexion.query('SELECT * FROM products', function(err, result){
var json = '';
if(err){
throw err;
}else{
json = JSON.stringify(result);
console.log('It's ok');
callback(null, json);
}
});
conexion.end();
}
It's just a little connection with local server and a simple query to show a movie list. 只需与本地服务器建立一点连接,并通过简单的查询即可显示电影列表。
At first, everythig is okay, but I wanna insert a form into my html code and users can check out a full review of the movie or just look a movie list separate by genres. 一开始,everythig可以,但是我想在html代码中插入一个表单,用户可以查看该电影的完整评论,也可以仅按流派查看电影列表。 I think that needs get and post methods but I know node-webkit doesn't support php.
我认为需要get和post方法,但是我知道node-webkit不支持php。 I was reading about Express module for Node.js, but I have wamp server.
我正在阅读有关Node.js的Express模块的信息,但是我有wamp服务器。
Thank you very much for your help! 非常感谢您的帮助!
You have this problem: 你有这个问题:
console.log('It's ok');
You close string with It's
. 您用
It's
关闭字符串。
Try this: 尝试这个:
console.log('It\'s ok');
or: 要么:
console.log("It's ok");
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.