Можете ли вы сказать мне, если эти соображения верны?Спасибо
Я могу использовать заполнители в запросе node.js-sqlite тремя способами:
1)Directly in the function arguments:
db.run("UPDATE tbl SET name = ? WHERE id = ?", "bar", 2);
/*first ? is a placeholder and it is replaced with "bar" value
before the query is executed
second ? is a placeholder and it is replaced with 2 value before
the query is executed*/
..............................................................................
2)As an array:
db.run("UPDATE tbl SET name = ? WHERE id = ?", [ "bar", 2 ]);
/*Second argument passed to db.run function is a parameters array.
first ? is a placeholder and it is replaced with first array
item("bar") before the query is executed
second ? is a placeholder and it is replaced with second array
item(2) before the query is executed*/
.............................................................................
3) Как объект с именованными параметрами:
db.run("UPDATE tbl SET name = $name WHERE id = $id", {
$id: 2,
$name: "bar"
});
//In this case, the second argument of the db.run function is an object.
/*$name placeholder in the UPDATE query, is replaced with the
$name key
value("bar") of the object before the query is executed
$id placeholder in the UPDATE query, is replaced with the $id key
value(2) of the object before the query is executed
placeholder and object key names must be the same.*/
..............................................................................
Все правильно?