HTML5SQL retrieve records from web databases using SELECT statements

心不动则不痛 提交于 2019-12-06 12:03:34

Sure. Selecting data with html5sql is really quite simple and can be accomplished with something as simple as:

html5sql.process(
    ["SELECT * FROM milestones;"],
    function(transaction, results, rowsArray){
      for(var i = 0; i < rowsArray.length; i++){
        //each row in the rowsArray represents a row retrieved from the database
        var id = rowsArray[i].ID;
        var Title = rowsArray[i].Title;
        var mYear = rowsArray[i].mYear;
        console.log("Retrieved Milestone: "+id+" - "+Title+" "+mYear);
      }
    },
    function(error, statement){
      //hande error here           
    }
);

If you want a more in-depth example I created a jsfiddle a while back which has actual working code showing the whole process of creating and populating a database and then selecting and retrieving data.

As the author of html5sql I apologize for the lack of documentation. I am working to improve the documentation on the site and add more live examples of how to do things.

This took me forever to figure out. You should really add that 3rd param for select results in your docs

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!