如何填充参数$cordovaSQLite作为我自己的数组
How to populate Parameter in $cordovaSQLite as my own array
我使用这些代码来执行$cordovaSQLite
插入。
var qst_master_content_data= {
qst_cnt_id :content.qst_cnt_id,
question_id :content.question_id,
qst_cnt_text :content.qst_cnt_text,
qst_cnt_options :content.qst_cnt_options,
qst_story:content.qst_story,
explanation :content.explanation,
lang_id :content.lang_id,
img_id :content.img_id,
dt_update :content.dt_update
};
var query = "INSERT INTO qst_master_content ( "+
"qst_cnt_id, "+
"question_id, "+
"qst_cnt_text, "+
"qst_cnt_options, "+
"qst_story, "+
"explanation, "+
"lang_id, "+
"img_id, "+
"dt_update "+
") VALUES (?,?,?,?,?,?,?,?,?)";
$cordovaSQLite.execute(db, query, qst_master_content_data).then(function(res)
{
console.log(res);
},
function(err)
{
console.log(err);
}
遗憾的是,插入没有成功插入。我试图使用qst_master_cotent = [1,2,3];
,然后它会好的。但这并不能使我的代码在这种格式上被重用。应该是:
var qst_master_content_data= {
qst_cnt_id :content.qst_cnt_id,
question_id :content.question_id,
qst_cnt_text :content.qst_cnt_text,
qst_cnt_options :content.qst_cnt_options,
qst_story:content.qst_story,
explanation :content.explanation,
lang_id :content.lang_id,
img_id :content.img_id,
dt_update :content.dt_update
};
以便将来可以对数据进行操作。我怎么能做到呢?
注意变量名。参数对象名称是qst_master_content。应该是这样的:
$cordovaSQLite.execute(db, query, qst_master_cotent)
使用这段代码
var db = window.sqlitePlugin.openDatabase({
name: "your.db"
});
db.transaction(populateClientDB, error, success);
function populateClientDB(tx) {
tx.executeSql("INSERT INTO qst_master_content (qst_cnt_id, question_id, qst_cnt_text, qst_cnt_options, qst_story, explanation, lang_id, img_id, dt_update) 'n'
VALUES (?,?,?,?,?,?,?,?,?)", [qst_master_cotent.qst_cnt_id, qst_master_cotent.question_id, qst_master_cotent.qst_cnt_text, qst_master_cotent.qst_cnt_options, qst_master_cotent.qst_story, qst_master_cotent.explanation, qst_master_cotent.lang_id, qst_master_cotent.img_id, qst_master_cotent.dt_update], function(tx, res) {
console.log("insertId: " + res.insertId + " -- probably 1");
console.log("rowsAffected: " + res.rowsAffected + " -- should be 1");
});
}
function error(error) {
console.log(error);
}
function success() {
}
谢谢
相关文章:
- 为什么不't Javascript对我的输入值进行了一些重新检查
- 可以't让我的if语句处理js中的html表单输入
- 我可以在json对象中添加一个函数吗
- AngularJS:我可以跳过函数参数回调吗
- 我的单元测试选项是什么
- 将输入字段中的文本提交到我的数据库,同时将其添加到我的列表中
- 我如何找到一个句子中的所有空格并替换忽略它们
- 我可以获得相对于被点击元素的确切点击位置吗
- 我的职位回报太快了,如何做出承诺
- HTML5音频加载和播放获胜'我不能在iPad上工作
- 我的jQuery插件参数没有正确启动,遇到了问题
- 如何识别我的网站中的慢速设备
- 我应该如何从xml文件构建一个javascript页面
- 如何将JSON数据导入我的ejs模板
- 我可以更改剑道UI网格吗's的外键值
- Javascript(jQuery)给了我奇怪的结果
- JQuery添加元素需要在我的js之前再次添加JQuery脚本
- 我已经创建了一个jquery转盘,并使用if条件来运行和停止转盘
- 知道为什么我的旋转木马不会自动更改图片吗
- 如何填充参数$cordovaSQLite作为我自己的数组