Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/android/220.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
如何在phone gap android中同步执行另一个tx.executeSql函数中的tx.executeSql函数_Android_Sqlite_Cordova 2.0.0 - Fatal编程技术网

如何在phone gap android中同步执行另一个tx.executeSql函数中的tx.executeSql函数

如何在phone gap android中同步执行另一个tx.executeSql函数中的tx.executeSql函数,android,sqlite,cordova-2.0.0,Android,Sqlite,Cordova 2.0.0,我正在创建一个应用程序,希望在其中从本地数据库获取数据。我有三张桌子。我想要的是,当我从第一个表中获取数据时,比如说从employe details中,我检查很少的条件,如果雇员是超级用户,那么它将从第二个表项目细节中获取数据。所以我想要的是,当员工是超级用户时,它应该开始从第二个表执行数据获取,然后再进一步移动。但是,当它获得超级用户条件时,一旦在其中找到tx.executeSql函数,它就会生成线程,并从第一个表继续进一步执行,完成后,开始从项目详细信息执行数据。 任何人都可以帮助我使这个执

我正在创建一个应用程序,希望在其中从本地数据库获取数据。我有三张桌子。我想要的是,当我从第一个表中获取数据时,比如说从employe details中,我检查很少的条件,如果雇员是超级用户,那么它将从第二个表项目细节中获取数据。所以我想要的是,当员工是超级用户时,它应该开始从第二个表执行数据获取,然后再进一步移动。但是,当它获得超级用户条件时,一旦在其中找到tx.executeSql函数,它就会生成线程,并从第一个表继续进一步执行,完成后,开始从项目详细信息执行数据。 任何人都可以帮助我使这个执行在我想要的流程中工作

function getusersdetails()
{
    db.transaction(function(tx){
        tx.executeSql('select * from users',[],function(tx,results){
            var dataset = results.rows.length;
            if(dataset>0)
            {
                for(var i=0;i<dataset;i++)
                {
                    if(results.rows.item(i).employ_type =='SU')
                    {
                        tx.executeSql('Select * from accessRites where user_Id = results.rows.item(i).user_id',[],function(tx,result){
                            //some execution here;
                        });
                    }
                    else if(results.rows.item(i).employ_type =='Manager')
                        {
                            tx.executeSql('Select * from usergroups where user_Id =  results.rows.item(i).user_id',[],function(tx,results){
                                // some execution here;
                            });
                        }
                    else
                    {
                        //some execution here;
                    }
                    //here some usere execution ;
                }
            }
        });
    });
函数getusersdetails() { 数据库事务(功能(tx){ tx.executeSql('select*from users',[],函数(tx,results){ var数据集=results.rows.length; 如果(数据集>0) {
对于(var i=0;i而言,
executeSql
回调始终异步执行

您应该编写代码,使每个“此处的某些执行”代码独立于任何其他代码

或者,您可以通过联接获取所需的所有数据,以便获得单个结果集:

tx.executeSql('SELECT*FROM users'+
'使用(用户Id)左加入帐户站点'+
'使用(用户_Id)左加入用户组',
[],功能(发送,结果){
对于(var i=0;i

注意:如果一个
用户的
访问权限
/
用户组
记录有多个匹配的
记录
记录,您将得到多个记录,结果中包含重复的
用户
数据。

伙计们,我只想问一下,如果条件满足,如何在另一个tx.executeSql中同步执行tx.executeSql函数对,然后继续执行..当你保密时,我们如何帮助你处理代码?@CL我已经放置了代码请将其从保留中移除…我需要再“重新打开”投票…我以同样的方式返回代码,但是如果条件为true时我想从另一个表中访问数据,那么在访问数据后应该继续执行。非同步回调无法继续。