如何从sqLite查询中检索对象?有问题

时间:2014-02-03 23:29:24

标签: javascript sqlite object

我正在查询本地数据库并尝试以对象数组的形式检索我的数据,以便能够在另一个阶段中操作它们。

下面是我的代码和范围,我可以访问我的对象以及我无法访问该对象的位置。

 function setStageOneup(){
        var teams = localStorage.teamsUp;
        var tournament_id = 1;
        var statement = "SELECT * FROM teams WHERE t_id= '"+tournament_id+"';";
        localStorage.teamsUp = "";
        var team_array = {};
        var myTest = callBack(function(val){

            var team = {};
            for(var i = 0; i < val.rows.length; i++)
            {   
                // teams_array[i]['id'] = val.rows.item(i).id
                 //console.log(val.rows.item(i).text)


                    team.id = val.rows.item(i).id;
                    team.t_id = val.rows.item(i).t_id;
                    team.m_t_id = val.rows.item(i).m_t_id;
                    team.name = val.rows.item(i).name;
                    team.weight = val.rows.item(i).weight;
                    team.goals = val.rows.item(i).goals;
                    team.win = val.rows.item(i).win;
                    team.draw = val.rows.item(i).draw;
                    team.lost = val.rows.item(i).lost;
                    team.misc = val.rows.item(i).misc;
                team_array[i] = team;

                console.log(team); // I am able to hee the output here

            }
            console.log(team_array); // I am able to hee the output here
        },statement);
        console.log(team_array); // I am unable to see here even though the variable is decleared in this scope
    }

谢谢,如果我遗漏了什么请告诉我。

0 个答案:

没有答案