Skip to content

Commit

Permalink
Modifying where to properly handle multiple values as is needed for a…
Browse files Browse the repository at this point in the history
… BETWEEN query
  • Loading branch information
Anthony Roldan authored and xavierlacot committed Jul 26, 2011
1 parent 4676613 commit bf1e55a
Showing 1 changed file with 12 additions and 1 deletion.
13 changes: 12 additions & 1 deletion joli.js
Expand Up @@ -700,7 +700,18 @@ joli.query.prototype = {
this.data.where = '';
}

this.data.where += expression.replace(/\?/gi, '"' + value + '"');
// handle replacing multiple values, as is needed in a BETWEEN query or similar
if(typeof(value) == "object") {
var i = 0;
while(expression.indexOf("?") != -1) { // replace question marks one at a time from the array
expression = expression.replace(/\?/i, value[i]);
i++;
}
this.data.where += expression;
} else {
this.data.where += expression.replace(/\?/gi, '"' + value + '"');
}

return this;
},

Expand Down

0 comments on commit bf1e55a

Please sign in to comment.