Mysql
 SQL >> Datenbank >  >> RDS >> Mysql

SQL Injection in Node.js verhindern

Verwenden Sie Prepared Statements mit Platzhaltern:

connection.query('SELECT * FROM table WHERE userid = ?', [message.author.id], function (err, rows) { /* ... */ });

Der Treiber bindet den Wert sicher und verhindert SQL Injection.

Manuelles Escaping ist nur ein Notbehelf, wenn Prepared Statements nicht verfügbar sind.