我知道我能做到;
// As an object with named parameters.
db.run("UPDATE tbl SET name = $name WHERE id = $id", {
$id: 2,
$name: "bar"
});
像这样使用prepare
语句怎么样?
var stmt = db.prepare("INSERT INTO tbl (column_one, column_two ) values ($column_one, $column_two)");
stmt.run("first value of column 1", "first value of column 1");
stmt.run("second value of column 1", "second value of column 1");
stmt.run("third value of column 1", "third value of column 1");
stmt.finalize();
如何将值绑定到特定的参数中?
发布于 2021-09-25 08:20:42
或者,您可以执行以下操作
var query = "INSERT INTO tbl (column_one, column_two ) values ($column_one, $column_two)";
db.run(query, {$column_one: "your value", $column_two: "your value"});
db.run(query, {$column_one: "your value", $column_two: "your value"});
db.run(query, {$column_one: "your value", $column_two: "your value"});
或with prepare语句
var stmt = db.prepare("INSERT INTO tbl (column_one, column_two ) values (?, ?)");
stmt.run("first value", "second value");
stmt.run("first value", "second value");
stmt.run("first value", "second value");
stmt.finalize();
https://stackoverflow.com/questions/69324216
复制相似问题