sqlite manager 中返回结果的相同查询是我如何在 sqlite manager 中创建数据库,在 sqlite manager中插入数据库并在 sqlite-manager 中检索值,而在 phonegap-android 中它返回我未定义。我需要像第三个快照这样的结果。我在 phonegap-android 中使用循环插入记录。这是插入代码:
function insertInUserPrayerTable() {
db.transaction(function(tx)
{for(var i = 0;i<checkedValueofCheckbox.length;i++)
{checkedValueofCheckboxInsertArray.push('INSERT INTO user_prayers'
+ '(prayer_id,user_id,date,status)'
+ ' VALUES("'
+ checkedValueofCheckbox[i]
+ '",'
+ window.localStorage
.getItem("userid") + ',"'
+ $('#datepicker').val() + '",'
+ statusofNamaz[i] +');');
console.log("array values:"+checkedValueofCheckboxInsertArray);
}
},errorCB,runInsertQuery());
}
function runInsertQuery() {
db
.transaction(
function(tx) {
for (var i = 0; i < checkedValueofCheckboxInsertArray.length; i++) {
tx
.executeSql(
checkedValueofCheckboxInsertArray[i],
[],
successCBrunInsertQuery,
errorCBrunInsertQuery);
}
},errorCB,successCB);
}
我不知道我做错了什么?
$('#showbtn')
.off('click')
.on('click', function() {
db.transaction(function(tx) {
tx.executeSql("SELECT date,group_concat(status)"
+ " FROM user_prayers WHERE user_id ='"+window.localStorage.getItem("userid")+"'"
+ " GROUP BY date",
[], successCBofselect, errorCBofselect);
}, errorCB, successCB);
});
function successCBofselect(tx,results) {
var htmlstring = "";
if (results != null && results.rows != null && results.rows.length > 0) {
console.log(results);<!-- [object SQLResultSet] -->
console.log(results.rows);<!-- [object SQLResultSetRowList] -->
for (var i = 0; i < results.rows.length; i++) {
alert(""+results.rows.length);<!-- 8-->
alert(""+results.rows.item(i)); <!-- [object object]-->
deleteDataTemp[i] = results.rows.item(i).status;
alert(""+deleteDataTemp[i]);<!-- undefined-->
htmlstring += '</div>';
}
$("#data").empty().append(htmlstring).trigger('create');
}
});
其中“checkedValueofCheckbox[i]”是一个包含所有选中和未选中复选框的值的数组,“statusofNamaz[i]”包含一个状态为“1”或“0”的数组插入 console.log 05-14 16:21:16.335 : I/Web 控制台(8505): 数组值: 插入用户祈祷 (prayer_id,user_id,date,status)VALUES("FAJR",1,"2013-05-15",1);, INSERT INTO user_prayers(prayer_id, user_id,date,status)VALUES("ZOHAR",1,"2013-05-15",1);, INSERT INTO user_prayers(prayer_id,user_id,date,status)VALUES("ASR",1,"2013-05 -15",0);, INSERT INTO user_prayers(prayer_id,user_id,date,status)VALUES("MAGHRIB",1,"2013-05-15",0);, INSERT INTO user_prayers(prayer_id,user_id,date,状态)值(“ISHA”,1,“2013-05-15”,0);在文件:
需要结果 1,1,0,0,0 只有状态,按日期分组