简体   繁体   English

科尔多瓦sqlite删除不起作用

[英]cordova sqlite delete not working

I am trying to delete a particular id from my SQLite DB after successful post inside an interval, but it is not working, although it prints "success" in the console. 在间隔内成功发布后,我试图从SQLite DB中删除特定的ID,但是它无法正常工作,尽管它在控制台中显示“成功”。

       $interval(function(){
       var db = $cordovaSQLite.openDB({ name: "allimage.db", location: 'default', bgType: 1 });
                 var query = "SELECT * FROM allcaseimage";
                  $cordovaSQLite.execute(db, query).then(function (result) {
                     var myRowsIds = [];

                     var len = result.rows.length;
                     for (var i=0; i<len; i++){
                        $scope.records_id =  result.rows.item(i).records_id;
                        $scope.caseimage =  result.rows.item(i).caseimage;

                    }

                      var request = $http({
                        method: "post",
                        url: "http://45.55.19.50/mobile/api/savecasepic.php",
                        data: {
                            records_id: $scope.records_id,
                            image : $scope.caseimage
                        },
                        headers: { 'Content-Type':'application/x-www-form-urlencoded; charset=UTF-8' }
                    });

                       request.success(function (data) {

                           var db = $cordovaSQLite.openDB({ name: "allimage.db", location: 'default', bgType: 1 });
                           var query = "DELETE FROM allcaseimage where records_id = '"+$scope.records_id+"'";
                                $cordovaSQLite.execute(db, query, []).then(function(res) {
                                  //success
                                }, function (err) {
                                    console.error(err);
                                });

                         })


                  }, function (error) {
                    $scope.showAlert('data error');
                  })
            },20000);

console screenshot 控制台屏幕截图

您可能需要提交事务。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM