0
Ich benutze AJAX, um Daten in meinen Node Client zu "holen", aber ich kann nicht herausfinden, wie man diese Daten an MySQL "anlegt". Irgendwelche Ideen?Hat jemand Node.JS verwendet, um MySQL zu aktualisieren
Ich benutze AJAX, um Daten in meinen Node Client zu "holen", aber ich kann nicht herausfinden, wie man diese Daten an MySQL "anlegt". Irgendwelche Ideen?Hat jemand Node.JS verwendet, um MySQL zu aktualisieren
Sie mysql npm Modul verwenden können: npm install mysql
var mysql = require('mysql');
var pool = mysql.createPool({
host: 'localhost'
user: 'youruser'
password: 'yourpassword'
database: 'yourdb'
});
pool.getConnection(function (err, connection) {
connection.query('INSERT INTO tbl_name (col1,col2) VALUES(' + theValueYouGotFromAjax + ',' + anotherValue + ')' + '\'', function (err, result) {
if (err) console.log(err);
console.log('Created ' + result.affectedRows + ' rows');
connection.release();
console.log('Connection returned to pool.');
});
Prüfbaustein Dokumentation: https://github.com/mysqljs/mysql/tree/v0.9