Commit 4811a414 by Orlando Vazquez

Tweak Database#execute binding

parent 569ffde4
......@@ -101,20 +101,24 @@ Database.prototype.execute = function (sql /* , bindings, callback */) {
}
self.prepare(sql, function (error, statement) {
function next (error) {
if (error) return callback(new Error("Error binding: " + error.toString()));
fetchAll(statement);
}
if (error) {
return callback(error);
}
if (bindings) {
statement.bind(bindings, function (error) {
if (error) {
return callback(
new Error("Binding error: " + error.toString()));
if (Array.isArray(bindings)) {
statement.bindArray(bindings, next);
}
else if (typeof(bindings) === 'object') {
statement.bindObject(bindings, next);
}
fetchAll(statement);
});
}
else {
fetchAll(statement);
next();
}
function fetchAll(statement) {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment