【发布时间】:2013-10-28 06:55:37
【问题描述】:
我正在创建一个应用程序,我想在其中从本地数据库中获取数据。我有 3 张桌子。我想要的是当我从第一个表中获取数据时说从员工详细信息中我检查了一些条件,如果员工是超级用户,那么它将从第二个表项目详细信息中获取数据。所以我想要的是当员工是超级用户时,它应该开始从第二个表中执行数据提取,然后进一步移动。但是发生的情况是,当它获得超级用户条件时,一旦在其中找到 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 ;
}
}
});
});
在上面的代码中,当用户类型为 su 时,它不会在检测到 tx.executeSql 函数后立即执行第二个函数,而是继续执行第一个查询,然后在 SU 条件下运行 tx.execute我想要的是如果用户类型是 Su 它应该完成其中的 tx.execute 函数,然后继续进一步执行,因为最后需要数据。
【问题讨论】:
-
伙计们,我只想问,如果条件为真,如何在另一个 tx.executeSql 中同步执行 tx.executeSql 函数,然后继续执行..
-
在您保密的情况下,我们如何为您的代码提供帮助?
-
@CL 我已经放置了代码,请从保留中删除它......
-
我需要再进行一次“重新开放”投票...
标签: android sqlite cordova-2.0.0