简体   繁体   English

Phonegap iOS数据库查询

[英]Phonegap iOS DB Query

I am using Phonegap 1.3.0, and want to develop an app which uses local storage. 我正在使用Phonegap 1.3.0,并且想要开发一个使用本地存储的应用程序。 Some googling brought me to sqlite, but i have had no success in implementing it in my app. 一些谷歌搜索使我进入了sqlite,但是在我的应用程序中实现它并没有成功。

https://github.com/davibe/Phonegap-SQLitePlugin https://github.com/davibe/Phonegap-SQLitePlugin

I tried this link but i am really not sure what this lawnchair.js is all about. 我尝试了此链接,但我真的不确定此grasschair.js的全部含义。 Sqlite is my priority but I can try other options too. 我优先考虑Sqlite,但我也可以尝试其他选择。 I also tried window.opendatabase() but it doesnt work in my app. 我也尝试了window.opendatabase(),但是在我的应用程序中不起作用。

Thanks in advance! 提前致谢!

Lawnchair is a wrapper over many storage methods. 草坪椅是许多存储方法的包装。 There is localstorage, sqlite, blackberry specific, and others. 有本地存储,sqlite,特定于黑莓等。
There are many adapters in lawnchair to store stuff. 草地椅上有许多适配器可以存放东西。
http://westcoastlogic.com/lawnchair/adapters/ http://westcoastlogic.com/lawnchair/adapters/
The way lawnchair works is, if an adapter is specified, it will use that, or if no adapter is specified and if the code of all adapters is appended to lawnchair.js file, then lawnchair checks which one to use in the order of they are appended and picks the first one it finds suitable. 草坪椅的工作方式是,如果指定了适配器,则它将使用该适配器,或者如果未指定适配器,并且所有适配器的代码都附加到grasschair.js文件中,则草坪椅将按其顺序检查使用哪个适配器被附加并选择它认为合适的第一个。

What makes lawnchair easy to use is that we don't have to deal with sql syntaxs (assuming u want to use sqlite adapter.) You just store and retrieve your data in JSON by 使草编椅易于使用的原因是,我们不必处理sql语法(假设您要使用sqlite适配器。),您只需通过以下方式将数据存储和检索为JSON:

table.save(key:"obj", name:{a:"aaaa", b:"bbbb"})

table.get(key:"obj", function(ob){
  //callback
})

and internally lawnchair will save data in sqlite. 内部草编将数据保存在sqlite中。
You can use any adapter, but all u have to use is the above syntax. 您可以使用任何适配器,但您仅需使用上述语法。 easy. 简单。 lawnchair is a powerful wrapper over many storage options. 草地椅是许多存储选项的强大包装器。 check it out 看看这个

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM