本文介绍了sql查询不工作在slite + phonegap(计数给定名称的表中的元素数)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我计数在该表中的元素退出的数量,但它不工作?
我试试这样

i counting the number of element exit in that table but it is not working?I try like that

alert($('.caseName_h').val());


代码被中断后

I am getting alert of this val ;After that code is break

var tt  =tx.executeSql('SELECT 1 FROM CaseTable WHERE CaseName ='+"'+ $('.caseName_h').val()+'");

我也这样调用
var tt = tx.executeSql('SELECT 1 FROM CaseTable WHERE CaseName ='+ $(。caseName_h)。val());
alert(tt)

I also call like this var tt =tx.executeSql('SELECT 1 FROM CaseTable WHERE CaseName ='+ $(".caseName_h").val()); alert(tt)

未定义

推荐答案

尝试这样...

db.transaction(function (tx) {
            var caseName_h = $('.caseName_h').val();
            $yoursql = 'SELECT 1 FROM CaseTable WHERE CaseName = "'+caseName_h+'"';
            tx.executeSql($yoursql, [], function (tx, results) {
                if ( results.rows.length == 0 ) {
                    console.log(results.rows);
                }
            });
});

这篇关于sql查询不工作在slite + phonegap(计数给定名称的表中的元素数)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

10-19 11:44