我想在 html5 数据库中传递变量进行搜索。贝娄是我想要的例子:
var sear= "Hello World" // for example
var test = sear.split(" ");
var test3 = "\"%"+ test.join('%\", \"%')+"%\"";
var test4 = [];
for (var i=2; i<=test.length; i++) {
test4[i] = " OR (D_Indications LIKE ?)";
}
var test5="SELECT * FROM DEMO WHERE (D_Indications LIKE ?)"+ test4.join(" ");
现在我希望它通过“Hello OR World”搜索数据库,它的代码是。
tx.executeSql(test5, [test3],function (tx, results) {
// display from database
});
但是当我将变量传递给它时它没有搜索,而是当我输入时它找到了tx.executeSql(test5, ["%Hello%", "%World%"]