Allow for single objects as bound parameters without wrapping in array (e.g. DB.query(sql, {string:isbn}))

This commit is contained in:
Dan Stillman 2006-09-20 23:20:11 +00:00
parent 302f0105bf
commit 93c15fc061

View file

@ -171,8 +171,10 @@ Scholar.DB = new function(){
} }
if (statement && params){ if (statement && params){
// If single parameter, wrap in an array // If single scalar value or single object, wrap in an array
if (typeof params != 'object' || params===null){ if ((typeof params != 'object' || params===null) ||
(params && typeof params == 'object' &&
params.constructor != Array)){
params = [params]; params = [params];
} }
@ -231,6 +233,7 @@ Scholar.DB = new function(){
Scholar.debug('Binding parameter ' + (i+1) Scholar.debug('Binding parameter ' + (i+1)
+ ' of type NULL', 5); + ' of type NULL', 5);
statement.bindNullParameter(i); statement.bindNullParameter(i);
break;
} }
} }
} }