Commit 4811a414 by Orlando Vazquez

Tweak Database#execute binding

parent 569ffde4
...@@ -101,20 +101,24 @@ Database.prototype.execute = function (sql /* , bindings, callback */) { ...@@ -101,20 +101,24 @@ Database.prototype.execute = function (sql /* , bindings, callback */) {
} }
self.prepare(sql, function (error, statement) { self.prepare(sql, function (error, statement) {
function next (error) {
if (error) return callback(new Error("Error binding: " + error.toString()));
fetchAll(statement);
}
if (error) { if (error) {
return callback(error); return callback(error);
} }
if (bindings) { if (bindings) {
statement.bind(bindings, function (error) { if (Array.isArray(bindings)) {
if (error) { statement.bindArray(bindings, next);
return callback( }
new Error("Binding error: " + error.toString())); else if (typeof(bindings) === 'object') {
} statement.bindObject(bindings, next);
fetchAll(statement); }
});
} }
else { else {
fetchAll(statement); next();
} }
function fetchAll(statement) { 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