钛合金更新查询问题 [英] Issue with update query in titanium alloy
问题描述
我是钛和合金框架的新手.我创建了模型来存储一些数据.我能够插入和检索数据.我不知道如何更新行.
I'm new to titanium and alloy framework. I have created the models to store some data. I am able to insert and retrieve the data. I don't know How to update the row.
按照我的建议,我做了以下,
As suggest I did as follows,
var userLang = Alloy.Collections.userLanguage;
var models = Alloy.createModel("userLanguage");
models.fetch({id: 1});
models.save({
languageID: langID,
languageText: lang
});
上面的代码没有显示任何错误,但是当我尝试从表中选择一行时,
The above code s not showing any error, But when I try to select a row from the table,
var userLang = Alloy.createModel('userLanguage');
userLang.fetch({
query: {
statement: "SELECT * FROM userLanguage WHERE id = ?;",
params: [ 1 ]
}
});
alert("Updated value : "+userLang.get("languageText"));
模型
exports.definition = {
config : {
"columns": {
"id": "integer",
"languageID": "integer",
"languageText": "text"
},
"adapter": {
"type": "sql",
"collection_name": "userLanguage"
}
}
};
所选行未按预期更新
推荐答案
...我需要钛查询...
...I need titanium query...
我猜你说的是 Backbone.如果是这样,那么您可以在下面看到如何更新模型的示例.
I guess that you are talking about Backbone. If so then below you can see an example how to update a model.
您可以在此处找到更多信息:http://docs.appcelerator.com/titanium/latest/#!/guide/Alloy_Sync_Adapters_and_Migrations
You can find more informations here: http://docs.appcelerator.com/titanium/latest/#!/guide/Alloy_Sync_Adapters_and_Migrations
var model = Alloy.createModel("userLanguage");
model.fetch({id: 1});
model.save({
languageID: langID,
languageText: lang
});
这篇关于钛合金更新查询问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!