How can I fetch data synchronously from cordova-sqlite?

前端 未结 3 1697
灰色年华
灰色年华 2021-01-06 07:07

Is it possible to fetch data synchronously from cordova-sqlite?

I have a table caseTable with fields (ID, caseName, date). Each row in that table corr

3条回答
  •  轻奢々
    轻奢々 (楼主)
    2021-01-06 07:45

    I do like this ..!!It is working..Thank for help

    function getallTableData(tx) {
         // tx.executeSql("DROP TABLE IF EXISTS a");
    
       tx.executeSql('SELECT * FROM CaseTable', [], querySuccess, errorCB);
    }
    
    
    
    
    function querySuccess(tx, result) {
    
    
        var len = result.rows.length;
        var countDoument=0
        $('#folderData').empty();
        for (var i = 0; i < len; i++) {
    
             alert(i)
    
             test1=result.rows.item(i).CaseName;
    
    
         Test1(test1, function(i) {
          return function(result_count) {
            countDoument = result_count; // here it count value 
            alert(result_count + "result_count") //alert is correct count value
            alert(i + "i"); 
    
            $('#folderData').append(
                '
  • ' + '' + '' + '

    ' + result.rows.item(i).CaseName + countDoument + '

    ' + '

    ' + result.rows.item(i).TextArea + '

    ' + '

    ' + result.rows.item(i).CaseDate + '

    ' +'' + i + ''+ '
    ' + '
    ' + '' + i + ''+ '
  • ' ); $('#folderData').listview('refresh'); }; }(i)); } } function Test1(test, callBack){ var x; db.transaction(function (tx) { $yoursql = 'SELECT * FROM "'+test+'" '; tx.executeSql($yoursql, [], function (tx, results) { x = results.rows.length + "TableName" + test; callBack(x); }); }); }

提交回复
热议问题